Retrieving parameters from request ASP Classic 3.0

筅森魡賤 提交于 2020-01-23 17:38:24

问题


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!


回答1:


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 %>


来源:https://stackoverflow.com/questions/16588425/retrieving-parameters-from-request-asp-classic-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!