HttpRequest[] : priority of cookies, form, querystring collections.

K

ken.prat

Given the following:

<script>document.cookie = "foo=cookie;";</script>
<form action="form.aspx?foo=query" method="post">
<input name="foo" type="hidden" value="fom" />
<input type="submit" />
</form>

What is the value of Request["foo"] server side? Experiment shows that
GET overwrites POST which overwrites the cookie. Is this documented
somwhere?

Ken Prat
 
B

Bruce Barker

the cookie is sent in a header field and has nothing to do with method, as
it always appears before any post data. the query string data is alo
seperate from the form post data.

so:

Request.QueryString["foo"] returns "query"
Request.Form["foo"] returns "fom"
Request.Cookie["foo"] returns "cookie"
Request.ServerVariables["foo"] returns null

Request["foo"] returns the first value found in the
above order

counting on this order is bad coding.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top