在面向对象的语言中,有种“万物皆对象”的说法。在上篇文章中介绍了httpruntime类,在该类收到请求之后,立即通过httpworkerrequest工作者对象对传递的参数进行分析和分解,创建方便网站应用程序处理的对象。与此相关的对象主要有,请求和响应两个对象。即httprequest和httpresponse类型。
httprequest定义在命名空间system.web下
对于每一个请求参数,httpruntime将创建一个类型为httprequest的对象。
这个类定义了大量的属性,用于表示关于http请求的参数。这些参数来源于工作者对象httpworkerrequest,但httprequest提供了更加简便的方式。
http的请求消息包括三部分,分别是:请求行,请求头,请求体。
下面看一下httprequest的常见属性。


输出结果
requesttype:get
httpmethod:get
rawurl:/test.aspx
url:http://192.168.1.105:8888/test.aspx
:
filepath:/test.aspx
currentexecutionfilepath:/test.aspx
path:/test.aspx
apprelativecurrentexecutionfilepath:~/test.aspx
physicalapplicationpath:d:\deeplearn\
physicalpath:d:\deeplearn\test.aspx
accepttypes:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
headers:name=cache-control,value=max-age=0
headers:name=connection,value=keep-alive
headers:name=accept,value=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
headers:name=accept-encoding,value=gzip, deflate, sdch
headers:name=accept-language,value=zh-cn,zh;q=0.8
headers:name=host,value=192.168.1.105:8888
headers:name=user-agent,value=mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/47.0.2526.106 safari/537.36
headers:name=upgrade-insecure-requests,value=1
params:name=all_http,value=http_cache_control:max-age=0 http_connection:keep-alive http_accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 http_accept_encoding:gzip, deflate, sdch http_accept_language:zh-cn,zh;q=0.8 http_host:192.168.1.105:8888 http_user_agent:mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/47.0.2526.106 safari/537.36 http_upgrade_insecure_requests:1
params:name=all_raw,value=cache-control: max-age=0 connection: keep-alive accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 accept-encoding: gzip, deflate, sdch accept-language: zh-cn,zh;q=0.8 host: 192.168.1.105:8888 user-agent: mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/47.0.2526.106 safari/537.36 upgrade-insecure-requests: 1
params:name=appl_md_path,value=/lm/w3svc/4/root
params:name=appl_physical_path,value=d:\deeplearn\
params:name=auth_type,value=
params:name=auth_user,value=
params:name=auth_password,value=
params:name=logon_user,value=
params:name=remote_user,value=
params:name=cert_cookie,value=
params:name=cert_flags,value=
params:name=cert_issuer,value=
params:name=cert_keysize,value=
params:name=cert_secretkeysize,value=
params:name=cert_serialnumber,value=
params:name=cert_server_issuer,value=
params:name=cert_server_subject,value=
params:name=cert_subject,value=
params:name=content_length,value=0
params:name=content_type,value=
params:name=gateway_interface,value=cgi/1.1
params:name=https,value=off
params:name=https_keysize,value=
params:name=https_secretkeysize,value=
params:name=https_server_issuer,value=
params:name=https_server_subject,value=
params:name=instance_id,value=4
params:name=instance_meta_path,value=/lm/w3svc/4
params:name=local_addr,value=192.168.1.105
params:name=path_info,value=/test.aspx
params:name=path_translated,value=d:\deeplearn\test.aspx
params:name=query_string,value=
params:name=remote_addr,value=192.168.1.105
params:name=remote_host,value=192.168.1.105
params:name=remote_port,value=3445
params:name=request_method,value=get
params:name=script_name,value=/test.aspx
params:name=server_name,value=192.168.1.105
params:name=server_port,value=8888
params:name=server_port_secure,value=0
params:name=server_protocol,value=http/1.1
params:name=server_software,value=microsoft-iis/10.0
params:name=url,value=/test.aspx
params:name=http_cache_control,value=max-age=0
params:name=http_connection,value=keep-alive
params:name=http_accept,value=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
params:name=http_accept_encoding,value=gzip, deflate, sdch
params:name=http_accept_language,value=zh-cn,zh;q=0.8
params:name=http_host,value=192.168.1.105:8888
params:name=http_user_agent,value=mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/47.0.2526.106 safari/537.36
params:name=http_upgrade_insecure_requests,value=1
contentencoding:system.text.utf8encoding
contentlength:0
contenttype:
browser:system.web.mobile.mobilecapabilities
useragent:mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/47.0.2526.106 safari/537.36
userhostaddress:192.168.1.105
userhostname:192.168.1.105
userlanguages:zh-cn,zh;q=0.8
博客地址:
<a href="http://www.cnblogs.com/wolf-sun">http://www.cnblogs.com/wolf-sun/</a>
博客版权:
本文以学习、研究和分享为主,欢迎转载,但必须在文章页面明显位置给出原文连接。
如果文中有不妥或者错误的地方还望高手的你指出,以免误人子弟。如果觉得本文对你有所帮助不如【推荐】一下!如果你有更好的建议,不如留言一起讨论,共同进步!
再次感谢您耐心的读完本篇文章。http://www.cnblogs.com/wolf-sun/p/5204778.html