Why does Request.QueryString ["key"] stop working?

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

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

<%= Request.QueryString[0] %>

I get http://myapp/folder/?key=valueon 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 understand what is happening?

+3
source share
5 answers

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

? Page = requested-page.aspx? Key = value

URL- . , ? url ?

+3

, QueryString Visual Studio, . , , .

0

-, Sitecore ( , QueryString), // ignoreUrl. Sitecore ; -)

0

/default.aspx?key = value, , [ "" ] param

0
source

you can use

Request.QueryString.Count();

and accordingly get the number of request modification code

0
source

Source: https://habr.com/ru/post/1753137/


All Articles