I asked this before but I’m stuck with another issue. Say, if I load my page like so:
http://localhost:57845/api.ashx?v=123&usr=&url=
and then try to do:
string strUser = context.Request["usr"];
string strURL = context.Request["url"];
both strUser and strURL will be set to “”, which I would expect.
But if call it like this:
http://localhost:57845/api.ashx?v=123
strUser will be null, which I would also expect, but strURL will be set to “/api.ashx”.
Why is that???
I believe this is coming from the
ServerVariablespart of the request. You’d likewise get a value if you asked forremote_addror any of the other server variables supported by IIS (assuming you’re coming through IIS).If you only want to get parameters from the query string, use the
QueryStringproperty:(I’d also strongly recommend that you get rid of the type-prefixes on your variable names, but that’s a different matter.)