views:

274

answers:

2

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 :)

A: 

Use <%=Request["myID"] %>

adatapost
This will check for all collections in Request including forms, querystring and params.
rahul
Nope, I still get the same result :(
Steven
I even t ry Request.RawUrl, and it outputs the same URL no matter what page I open :(
Steven
+2  A: 

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
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
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, stringcustom){ return context.Request.RawUrl;}
Johan Kronberg
That way there's no need to specify each param name.
Johan Kronberg