Asp遍历Request,Session和Application服务器对象的代码分享
作者: 来源: 发布时间:2011-6-21 15:17:45 点击:
下面提供给大家分享的是关于Asp遍历Request,Session和Application服务器对象的代码,希望对大家有用。
一 遍历Request
方式1:
<%
For Each r In Request.QueryString
Response.Write "Request("""&r&""") = " & Request(r)
Response.Write "<p>"
Next
%>
方式1:
<%
For Each r In Request.QueryString
Response.Write "Request("""&r&""") = " & Request(r)
Response.Write "<p>"
Next
%>
方式2:
<%
For i = 1 To Request.QueryString.Count
Response.Write "Request("""&Request.QueryString.Key(i)&""") = " & Request.QueryString(Request.QueryString.Key(i))
Response.Write "<p>"
Next
%>
<%
For i = 1 To Request.QueryString.Count
Response.Write "Request("""&Request.QueryString.Key(i)&""") = " & Request.QueryString(Request.QueryString.Key(i))
Response.Write "<p>"
Next
%>
将QueryString改为Form,即可遍历Post变量。
二 遍历Session
<%
Session("key1")="value1"
Session("key2")="value2"
For Each s In Session.Contents
Response.Write "Session("""&s&""") = " & Session(s)
Response.Write "<p>"
Next
%>
<%
Session("key1")="value1"
Session("key2")="value2"
For Each s In Session.Contents
Response.Write "Session("""&s&""") = " & Session(s)
Response.Write "<p>"
Next
%>
三 遍历Application
<%
Application("key1")="value1"
Application("key2")="value2"
For Each a In Application.Contents
Response.Write "Application("""&a&""") = " & Application(a)
Response.Write "<p>"
Next
%>
<%
Application("key1")="value1"
Application("key2")="value2"
For Each a In Application.Contents
Response.Write "Application("""&a&""") = " & Application(a)
Response.Write "<p>"
Next
%>
上一篇:ASP通用防注入代码分享 下一篇: ArrayList的使用说明
[收藏此文章]