What Request.Params["key"] do?
Hi I want to know what Request开发者_C百科.Params["key"]
does? Where is it used?
Request.Params
is a combination of the keys/values you'll find in Request.Querystring
, Request.Form
, Request.Cookies
, Request.ServerVariables
(in that order)
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:
- QueryString
- Form
- Cookies
- ServerVariables
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#
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:
- Query-string parameters.
- Form fields.
- Cookies.
- Server variables
In that order.
Does this answer your question, MSDN info. It says exactly what it does, found simply by googling "Request.Params". If you want more info, could you be more specific in your question?
it holds information from a httprequest object, this MSDN link shows the type of information you can expect to find in it
MSDN
精彩评论