Why has Request.QueryString["key"] stopped working?

I have a simple web form called default.aspx in the folder structure webroot/folder/

When I navigate to http://myapp/folder/?key=value the page returns fine and when I call

<%= Request.QueryString[0] %>

I get http://myapp/folder/?key=value rendered on the page. However if I call

<%= Request.QueryString["key"] %>

I get nothing, and when I call

<%= Request.QueryString[1] %>

I get Index was out of range. Must be non-negative and less than the size of the collection.

This seems like a very trivial problem but I can't figure out what's going on?!


So it turns out that behind the scenes Sitecore turns the querystring into


But the url in the browser looks as requested. Obviously sticking a second ? in the actual url makes everything after the second ? disappear

If you apply a breakpoint, and then hover over the QueryString in Visual Studio then you should be able to view all of the keys. Alternatively you can foreach over the collection and print out the key names to see if it's slightly different to what you're expecting.

If you're doing something that isn't really supposed to be under Sitecore control (although I have never found it to make working with the QueryString collection impossible), try adding your /folder/ to the ignoreUrl setting. Sitecore will get out of your hair, then ;-)

your query string should be in /default.aspx?key =value then you will be able to access using ["key"] param

you can use


and get the count of querystring modifiy code accordingly

Need Your Help

What's the most efficient way to compare two blocks of memory in the D language?

performance algorithm d binary-search low-level

I need a comparison function for blocks of memory for doing binary searches on arrays of bytes in the D programming language. It does not need to have any useful semantics. It only needs to be fa...

How to drag and drop different list box items together

javascript jquery jquery-ui-sortable

I have 2 list boxes. It is placed adjacent to each other. User can sort each list individually and then I have provided a checkbox. If checkbox is checked, then the items gets bound each other