Suppose I have a url like this:
http://www.example.com?key=123&KEY=198
Then what will be result of
request.querystring("key")
and
request.querystring("KEY")
I am a bit confused.
Suppose I have a url like this:
http://www.example.com?key=123&KEY=198
Then what will be result of
request.querystring("key")
and
request.querystring("KEY")
I am a bit confused.
@gbjbaanb's answer is incorrect: The RFCs only specify the allowed character set for the query string. Like the path and fragment components of the URI, the query URI component only has meaning only to the authority providing the resource.
It is entirely up to that authority on whether this stuff is case-sensitive or not.
In the case of C# and IIS, the backing store for the parsed query string in the
HttpRequest
object is aSystem.Collections.Specialized.NameValueCollection
which happens to be case-insensitive (by default).Since that class offers other constructors allow different equality comparers to be provided, there is absolutely nothing to prevent an implementation from making it case-sensitive.
Further, since the page itself (and the client-side javascript) have access to the raw URI, they are free to do whatever they want with it.
If the query string is built as a result of an HTML form submission, the keys (names) come from the value of the form controls
name
attribute, which the HTML specs say is case-sensitive. But as near as I know, nobody really does that.So, at the end of the day, you have to know what the request handler is expecting in your query string. It might (or it might not) be case-sensitive.
The RFC for URIs says:
Note that scheme ("http" here), host (server name) are case-insensitive but should be in lowercase anyway. The rest is case-sensitive unless you're using a different scheme that explicitly says it should be insensitive.
So key and KEY are different things in all http-based URIs according to the spec.
According to hurl.it,
key
will be equal to123
andKEY
,198
. They will be accessible as two different querystrings.