i just want to get full querystring from url.
Request.QueryString
Request.ServerVariables["QUERY_STRING"]
Can i use any one of these? which way is preferred?
Thanks
Request.ServerVariables["QUERY_STRING"]
contains the entire query string, that is everything after the question mark but before the fragment identifier #
http://msdn.microsoft.com/en-us/library/ms525396(v=vs.90).aspx
Request.QueryString
Contains a collection allowing you to get individual elements.
Using following syntax:
Request.QueryString(variable)[(index)|.Count]
This collection is generated from the ServerVariables collection. The values in this collection are automaticly UrlDecoded.
So if you call Request.QueryString.ToString()
, it is inherently the same as Request.ServerVariables["QUERY_STRING"]
, but with UrlDecoding.
So you should use this as it is safer.
Request.QueryString(variable)[(index)|.Count]
http://msdn.microsoft.com/en-us/library/ms524784(v=vs.90).aspx
http://msdn.microsoft.com/en-us/library/ms524784(v=vs.90).aspx
The QueryString collection is a parsed version of the QUERY_STRING variable in the ServerVariables collection. It enables you to retrieve the QUERY_STRING variable by name. The value of Request.QueryString(parameter) is an array of all of the values of parameter that occur in QUERY_STRING. You can determine the number of values of a parameter by calling Request.QueryString(parameter).Count. If a variable does not have multiple data sets associated with it, the count is 1. If the variable is not found, the count is 0.
To reference a QueryString variable in one of multiple data sets, you specify a value for index. The index parameter can be any value between 1 and Request.QueryString(variable).Count. If you reference one of multiple QueryString variables without specifying a value for index, the data is returned as a comma-delimited string.
When you use parameters with Request.QueryString, the server parses the parameters sent to the request and returns the specified data. If your application requires unparsed QueryString data, you can retrieve it by calling Request.QueryString without any parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With