您好,登录后才能下订单哦!
使用asp.net怎么遍历Request信息?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
ASP.NET 是开源,跨平台,高性能,轻量级的 Web 应用构建框架,常用于通过 HTML、CSS、JavaScript 以及服务器脚本来构建网页和网站。
在服务端获取从客户端发送过来的所有数据信息;
public void ProcessRequest(HttpContext context) { //打印所有参数信息 context.Response.Write("Params:"); for (int i = 0; i < context.Request.Params.Count; i++) { context.Response.Write("<li>" + context.Request.Params.Keys[i].ToString() + " = " + context.Request.Params[i].ToString()); } context.Response.Write("<hr>"); //打印form信息 context.Response.Write("Form:"); for (int i = 0; i < context.Request.Form.Count; i++) { context.Response.Write("<li>" + context.Request.Form.Keys[i].ToString() + " = " + context.Request.Form[i].ToString()); } context.Response.Write("<hr>"); //打印query信息 context.Response.Write("QueryString:"); for (int i = 0; i < context.Request.QueryString.Count; i++) { context.Response.Write("<li>" + context.Request.QueryString.Keys[i].ToString() + " = " + context.Request.QueryString[i].ToString()); } context.Response.Write("<hr>"); //打印cookies信息 context.Response.Write("Cookies:"); for (int i = 0; i < context.Request.Cookies.Count; i++) { context.Response.Write("<li>" + context.Request.Cookies.Keys[i].ToString() + " = " + context.Request.Cookies[context.Request.Cookies.Keys[i].ToString()].Value); } context.Response.ContentType = "text/html"; }
1)、query_param
2)、headers
3)、form_param
4)、cookies
Params:
str = str
str1 = str1
form_1 = form_1
form_2 = form_2
ASP.NET_SessionId = 2eln4eqa2uv0hawyks50kfad
DisablePoint = true
QrcodePrefix =
UM = http://192.168.2.121/PsUM
MasterVisitor = 19
CanRegister = True
LoopTime = 10
CanDownload = {"1":false}
TotalVisitorNum = {"1":6}
cookie_test = test
ALL_HTTP = HTTP_CACHE_CONTROL:no-cache HTTP_CONNECTION:keep-alive HTTP_CONTENT_LENGTH:278 HTTP_CONTENT_TYPE:multipart/form-data; boundary=--------------------------358496475944465509800748 HTTP_ACCEPT:*/* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_COOKIE:ASP.NET_SessionId=2eln4eqa2uv0hawyks50kfad; DisablePoint=true; QrcodePrefix=; UM=http://192.168.2.121/PsUM; MasterVisitor=19; CanRegister=True; LoopTime=10; CanDownload={"1":false}; TotalVisitorNum={"1":6}; cookie_test=test HTTP_HOST:localhost:3805 HTTP_USER_AGENT:PostmanRuntime/7.3.0 HTTP_HEADER_1:header_1 HTTP_HEADER_2:header_2 HTTP_POSTMAN_TOKEN:1f778868-3222-479a-9863-d65ca4881a2b
ALL_RAW = Cache-Control: no-cache Connection: keep-alive Content-Length: 278 Content-Type: multipart/form-data; boundary=--------------------------358496475944465509800748 Accept: */* Accept-Encoding: gzip, deflate Cookie: ASP.NET_SessionId=2eln4eqa2uv0hawyks50kfad; DisablePoint=true; QrcodePrefix=; UM=http://192.168.2.121/PsUM; MasterVisitor=19; CanRegister=True; LoopTime=10; CanDownload={"1":false}; TotalVisitorNum={"1":6}; cookie_test=test Host: localhost:3805 User-Agent: PostmanRuntime/7.3.0 header_1: header_1 header_2: header_2 Postman-Token: 1f778868-3222-479a-9863-d65ca4881a2b
APPL_MD_PATH = /LM/W3SVC/34/ROOT
APPL_PHYSICAL_PATH = D:\vsproject\Projects\WebApplication1\WebApplication1\
AUTH_TYPE =
AUTH_USER =
AUTH_PASSWORD =
LOGON_USER =
REMOTE_USER =
CERT_COOKIE =
CERT_FLAGS =
CERT_ISSUER =
CERT_KEYSIZE =
CERT_SECRETKEYSIZE =
CERT_SERIALNUMBER =
CERT_SERVER_ISSUER =
CERT_SERVER_SUBJECT =
CERT_SUBJECT =
CONTENT_LENGTH = 278
CONTENT_TYPE = multipart/form-data; boundary=--------------------------358496475944465509800748
GATEWAY_INTERFACE = CGI/1.1
HTTPS = off
HTTPS_KEYSIZE =
HTTPS_SECRETKEYSIZE =
HTTPS_SERVER_ISSUER =
HTTPS_SERVER_SUBJECT =
INSTANCE_ID = 34
INSTANCE_META_PATH = /LM/W3SVC/34
LOCAL_ADDR = ::1
PATH_INFO = /test.ashx
PATH_TRANSLATED = D:\vsproject\Projects\WebApplication1\WebApplication1\test.ashx
QUERY_STRING = str=str&str1=str1
REMOTE_ADDR = ::1
REMOTE_HOST = ::1
REMOTE_PORT = 12131
REQUEST_METHOD = POST
SCRIPT_NAME = /test.ashx
SERVER_NAME = localhost
SERVER_PORT = 3805
SERVER_PORT_SECURE = 0
SERVER_PROTOCOL = HTTP/1.1
SERVER_SOFTWARE = Microsoft-IIS/10.0
URL = /test.ashx
HTTP_CACHE_CONTROL = no-cache
HTTP_CONNECTION = keep-alive
HTTP_CONTENT_LENGTH = 278
HTTP_CONTENT_TYPE = multipart/form-data; boundary=--------------------------358496475944465509800748
HTTP_ACCEPT = */*
HTTP_ACCEPT_ENCODING = gzip, deflate
HTTP_COOKIE = ASP.NET_SessionId=2eln4eqa2uv0hawyks50kfad; DisablePoint=true; QrcodePrefix=; UM=http://192.168.2.121/PsUM; MasterVisitor=19; CanRegister=True; LoopTime=10; CanDownload={"1":false}; TotalVisitorNum={"1":6}; cookie_test=test
HTTP_HOST = localhost:3805
HTTP_USER_AGENT = PostmanRuntime/7.3.0
HTTP_HEADER_1 = header_1
HTTP_HEADER_2 = header_2
HTTP_POSTMAN_TOKEN = 1f778868-3222-479a-9863-d65ca4881a2b
Form:
form_1 = form_1
form_2 = form_2
QueryString:
str = str
str1 = str1
Cookies:
ASP.NET_SessionId = 2eln4eqa2uv0hawyks50kfad
DisablePoint = true
QrcodePrefix =
UM = http://192.168.2.121/PsUM
MasterVisitor = 19
CanRegister = True
LoopTime = 10
CanDownload = {"1":false}
TotalVisitorNum = {"1":6}
cookie_test = test
关于使用asp.net怎么遍历Request信息问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。