Is there a built in collection that checks both request.form and request.querystring
views:
39answers:
2The HttpRequest
's Params
property is a combination of its QueryString
, Form
, ServerVariables
, and Cookies
properties.
You can also directly index the Request
for the same result: Request["ItemId"]
No, there isn't. The Request.Params collection contains those, but it also contains the values from the ServerVariables and Cookies collections.
I recommend that you look in the specific colletion(s) where you expect the values instead of getting values from all over the place. If you later on happens to add a cookie somewhere in the site that has the same name as one of your form or querystring values, you will suddenly get the cookie value instead. It can be quite hard to figure out why a form or querystring value starts to disappear for no apparent reason in code where you didn't change anything...