Request、Response、Server对象
1、
Request.QueryString["控件名"] | 适合于get方式提交的表单 |
Request.Form["控件名"] | 适合于post方式提交的表单 |
Request["控件名"] | 同时适合于get和post方式提交的表单 |
2、
Request封装了客户端请求信息。Request的常见属性如下:
属性名 |
值类型 |
说明 |
ApplicationPath |
String |
获取请求的资源在网站上的根路径 |
ContentEncoding |
Encoding |
设置请求对象的编码 |
Cookies |
HttpCookieCollection |
客户端发送到服务器的Cookie集合 |
QueryString |
NameValueCollection |
当前请求的查询字符串集合 |
UrlReferrer |
Uri |
获取用户由哪个url跳转到当前页面 |
Response代表了服务器响应对象。每次客户端发出一个请求的时候,服务器就会用一个响应对象来处理这个请求,处理完这个请求之后,服务器就会销毁这个相应对象,以便继续接受其它客服端请求。
Response常用属性如下:
属性名 |
值类型 |
说明 |
Charset |
string |
表示输出流的所使用的字符集 |
ContentEncoding |
Encoding |
设置输出流的编码 |
ContentLength |
Int |
输出流的字节大小 |
ContentType |
string |
输出流的HTTP MIME类型 |
Cookies |
HttpCookieCollection |
服务器发送到客户端的Cookie集合 |
Output |
TextWriter |
服务器响应对象的字符输出流 |
RedirectLocation |
string |
将当前请求重定向 |
Response常用方法
属性名 |
返回值类型 |
说明 |
AppendCookie |
void |
向响应对象的Cookie集合中增加一个Cookie |
Clear |
void |
清空缓冲区中的所有内容输出 |
Close |
void |
关闭当前服务器到客户端的连接 |
End |
void |
终止响应,并且将缓冲区中的输出发送到客户端 |
Redirect |
void |
重定向当前请求 |
Server对象是用于获取服务器的相关信息的对象。它常用方法如下:
属性名 |
返回值类型 |
说明 |
Execute |
void |
执行指定的资源,并且在执行完之后再执行本页的代码 |
HtmlDecode |
string |
消除对特殊字符串编码的影响 |
HtmlEncode |
string |
对特殊字符串进行编码 |
MapPath |
string |
获取指定相对路径在服务器上的无力路径 |
Transfer |
void |
停止执行当前程序,执行指定的资源 |
UrlDecode |
string |
对路径字符串进行解码 |
UrlEncode |
string |
对路径字符串进行编码 |
![](http://www.cnblogs.com/images/cnblogs_com/wnan/251197/o_r_http_imgload.jpg)