Why does Request["whatever"] return the cookie value?

39 Views Asked by At

From what I understand:

Request.Form["whatever"] will return the value from the form POST collection Request.QueryString["whatever"] will return the value from the QueryString collection (or GET) Request["whatever"] will return the value from the POST collection (if it exists) or the QueryString collection, in that order

However, I have seen that if there's a cookie called "whatever" and there is no value for "whatever" found in either POST or QueryString collections, the cookie value will be returned.

Am I mistaken or is this in fact what happens by design in ASP.Net MVC 5?

1

There are 1 best solutions below

1
Andrei On BEST ANSWER

From the docs:

gets the specified object from the Cookies, Form, QueryString, or ServerVariables collections

So yes, it is very much by design that Request["whatever"] returns a cookie value.