Domanda

Is there a problem or difference between retrieving the request parameter as follows:

Request("<ParamName>")

Instead of:

Request.Form("<ParamName>") or
Request.QueryString("<ParamName>") ?

Thanks in advance!

È stato utile?

Soluzione

Request.Form() will get values that are POSTed. Request.QueryString() will contain values from the query string. Request() will contain the POSTed value, unless there is a QueryString value for the same name, in which case it will contain the QueryString value.

I think cookies can be involved too, but my memory is a bit foggy on how they fit into the stack.

If you care about the value coming from a POSTed form, then use Request.Form(), if you care about a URL querystring value then use Request.QueryString(). If you don't care, just use Request().

Quick sample to test:

<% OPTION EXPLICIT %>
<%
    dim vname : vname = "test"

    dim r   : r   = request(vname)
    dim r_f : r_f = request.form(vname)
    dim r_q : r_q = request.querystring(vname)

%>
POST:<br />
<form method="post">
<input type="text" name="test" value="Posted Form Value">
<input type="submit" name = "">
</form>

<hr>

<a href='?test=<% = Server.HtmlEncode("Querystring in URL") %>'>GET</a>

<hr>
request: <% = r %>

<hr>
request.form: <% = r_f %>

<hr>
request.querystring: <% = r_q %>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top