Hi I want to know what Request.Params["key"]
does? Where is it used?
The key
part is the indexer of the NameValueCollection
. It can be either a string or numeric index into the collection.
If you use a string, it will return the value associated with the string, if you use an int, in will return the item that is in that index of the collection.
It combines all of the following NameValuePairs, in this order:
So, if you want to get the value of an object with the string key "myKey" that might be in any of the above (assuming you don't care which one), you would use:
var myValue = Request.Parameters["myKey"]; // C#
Request.Params
is a combination of the keys/values you'll find in Request.Querystring
, Request.Form
, Request.Cookies
, Request.ServerVariables
(in that order)
It returns the value associated with "key".
I believe is looks among the QueryString parameters, the Form parameters, the cookies and the server varaibles looking for a match.
Detailed in the MSDN article on Request.Params. The "key" is a string representing which item in the list you want.
As opposed to Request.Form or Request.QueryString, Request.Params can return you data from:
In that order.
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