在第三方页面传递参数这个思路倒是的确可以省下一些代码,至少我以前是从没这样子传过。
<%
pass form objects submitted by a form g
et
if request.querystring.count>0 then
qstr="?"
for each x in request.querystring
qstr = qstr & x & "=" write name of parameter
qstr = qstr & server.urlencode(request.querystring(x)) & "&" write value of parameter
next
qstrsz = len(qstr)-1
qstr = left(qstr,qstrsz)
else
qstr=""
end if
response.redirect("yoururl.asp" & qstr)
%>
the next example shows how to build the submitted parameters from a form post. the procedure reads all posted objects and builds a querystring parameter.
<%
pass form objects submitted by a form g
et
if request.form.count>0 then
qstr="?"
for each x in request.form
qstr = qstr & x & "=" write name of parameter
qstr = qstr & server.urlencode(request.form(x)) & "&" write value of parameter
next
qstrsz = len(qstr)-1
qstr = left(qstr,qstrsz)
else
qstr=""
end if
response.redirect("yoururl.asp" & qstr)
%>
the next code example may be used as a test asp page to redirect to. it reads the querystring and builds a table to display the parameter name and value passed.
<%@ language=vbscript %>
<html>
<body>
<%
response.write "<table border=1><tr><th>parameter</th><th>value</th></tr>"
for each x in request.querystring
response.write "<tr><td>" & x & "</td><td>" write name of parameter
response.write request.querystring(x) & "</td></tr>" write value of parameter
next
response.write "</table>"
%>
</body>
</html>
当然,上面这个东西的改进版本就简洁多了,再看这个
<%
if
request.querystring.count > 0 then
response.redirect("yoururl.asp?" &
request.querystring
else
if
request.form.count > 0 then
response.redirect("yoururl.asp?" &
request.form)
else
response.write("no data sent")
end
if
end if
%>
原来可以整个抓取的,我也是刚刚知道,不敢独吞,拿出来共享
