0

I'm trying to retrieve the value of myID from my URL. I'm testing this using <%=Request.QueryString["hotelid"] %>.

It only works the first time the page is loaded either in a new browser, or if my project has been rebuild.

My URL string is typical: http://my/path/to/site/?hotelid=2.

If I try <%=Request.QueryString %>, I'm also getting other values as well. Values I do not see inthe URL string.

What am I missing here?

Update:
Using <%=Request.RawUrl%>, I get the following results:
/Util/NotFound.aspx?404;http://localhost/en/Tjenester/Hotellguiden-2/Hotel-informasjon/?hotelid=3

I have NO idea what the /Util/NotFound.aspx?404 is or where it comes from.

My URL looks like this:
http://localhost/en/Tjenester/Hotellguiden-2/Hotel-informasjon/?hotelid=2

Update 2: I'm currently investigating if it is EPiServer CMS that is using some kind of caching.

Update 3: I have solved it. EPiServer is using EPnCachePolicyTimeout which isset to 1 hour. Setting this to 0 (zero) solved my problem.

Sometimes is really helps just writing aboutthe problem here, talking "aloud" about it and voila :)

Steven
  • 19,224
  • 47
  • 152
  • 257

1 Answers1

3

You need to turn off caching or add your parameter names to the config attribute httpCacheVaryByParams or overwrite the custom caching key method and make it diff on every querystring parameter.

Johan Kronberg
  • 1,086
  • 7
  • 12
  • Ok, thanks for the links. Not sure I like the approach of having to add variable names to the web.config as I code along! – Steven Aug 18 '09 at 08:10
  • For EPiServer 5 R2 and later I always use this approach: In web.config: httpCacheExpiration="0:1:0" httpCacheability="Public" httpCacheVaryByCustom="jk" httpCacheVaryByParams="needs-a-value-but-not-used" In Global: public override string GetVaryByCustomString(HttpContext context, string custom) { return context.Request.RawUrl; } – Johan Kronberg Aug 18 '09 at 10:45
  • That way there's no need to specify each param name. – Johan Kronberg Aug 18 '09 at 10:49