在第三方頁面傳遞參數這個思路倒是的確可以省下一些代碼,至少我以前是從沒這樣子傳過。
<%
'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
%>
原來可以整個抓取的,我也是剛剛知道,不敢獨吞,拿出來共享