首页 技术 正文
技术 2022年11月15日
0 收藏 992 点赞 2,495 浏览 5093 个字

      Request对象派生自HttpRequest类,使 ASP.NET 能够读取客户端在 Web 请求期间发送的 HTTP 值,从客户端获取信息,浏览器的种类,用户输入表单的数据,Cookies,客户端认证等,对应的Response.Write 负责处理前者获取的东西。

构造函数:public HttpRequest(string filename, string url, string queryString)

      filename:与请求关联的文件的名称;url:有关当前请求的 URL 的信息;queryString:与请求一起发送的整个查询字符串(’?’ 之后的所有内容)。
属性:
名称 用法 说明
AcceptTypes String[] arr = Request.AcceptTypes; 获取客户端支持的 MIME 接受类型的字符串数组。
AnonymousID Request.AnonymousID 获取该用户的匿名标识符(如果存在)。
ApplicationPath Request.ApplicationPath 获取服务器上 ASP.NET 应用程序的虚拟应用程序根路径。
AppRelativeCurrentExecutionFilePath Request.AppRelativeCurrentExecutionFilePath 获取应用程序根的虚拟路径,并通过对应用程序根使用波形符 (~) 表示法(例如,以“~/page.aspx”的形式)使该路径成为相对路径。
Browser Request.Browser 获取或设置有关正在请求的客户端的浏览器功能的信息。
ClientCertificate Request.ClientCertificate 获取当前请求的客户端安全证书。
ContentEncoding String EncodingType;
EncodingType = Request.ContentEncoding.EncodingName;
获取或设置实体主体的字符集。
ContentLength Request.ContentLength 指定客户端发送的内容长度(以字节计)。
ContentType String str;
str = Request.ContentType;
获取或设置传入请求的 MIME 内容类型。
Cookies HttpCookie MyCookie;
MyCookieColl = Request.Cookies;
获取客户端发送的 Cookie 的集合。
CurrentExecutionFilePath sw.WriteLine(Server.HtmlEncode(Request.CurrentExecutionFilePath)); 获取当前请求的虚拟路径。
CurrentExecutionFilePathExtension Request。CurrentExecutionFilePathExtension 获取 CurrentExecutionFilePath 属性中指定的文件名的扩展名。
FilePath Request.FilePath 获取当前请求的虚拟路径。
Files HttpFileCollection Files = Request.Files; 获取采用多部分 MIME 格式的由客户端上载的文件的集合。
Filter Request.Filter = new QQQ1(Request.Filter); 获取或设置在读取当前输入流时要使用的筛选器。
Form

NameValueCollection coll = Request.Form;

String[] arr1 = coll.AllKeys;

 获取窗体变量集合。

Headers

NameValueCollection coll = Request.Headers;

String[] arr1 = coll.AllKeys;

获取 HTTP 头集合。
HttpChannelBinding  

获取当前 HttpWorkerRequest 实例的 ChannelBinding 对象。

HttpMethod sw.WriteLine(Server.HtmlEncode(Request.HttpMethod)); 获取客户端使用的 HTTP 数据传输方法(如 GET、POST 或 HEAD)。
InputStream System.IO.Stream str = Request.InputStream; 获取传入的 HTTP 实体主体的内容。
IsAuthenticated Request.IsAuthenticated 获取一个值(true or false),该值指示是否验证了请求。
IsLocal Request.IsLocal 获取一个值(true or false),该值指示是否来自本地计算机。
IsSecureConnection Request.IsSecureConnection 获取一个值(true or false),指示 HTTP 连接是否使用安全套接字(即 HTTPS)。
Item   QueryStringFormCookiesServerVariables 集合获取指定的对象。
LogonUserIdentity if (!Request.LogonUserIdentity.IsAuthenticated)
            Response.Redirect(“LoginPage.aspx”);
获取当前用户的 WindowsIdentity 类型。
Params NameValueCollection pColl = Request.Params; 获取 QueryStringFormCookiesServerVariables 项的组合集合。
Path Request.Path 获取当前请求的虚拟路径。
PathInfo sw.WriteLine(Server.HtmlEncode(Request.PathInfo)); 获取具有 URL 扩展名的资源的附加路径信息。
PhysicalApplicationPath sw.WriteLine(Server.HtmlEncode(Request.PhysicalApplicationPath)); 获取当前正在执行的服务器应用程序的根目录的物理文件系统路径
PhysicalPath sw.WriteLine(Server.HtmlEncode(Request.PhysicalPath)); 获取与请求的 URL 相对应的物理文件系统路径。
QueryString string fullname1 = Request.QueryString[“fullname”];
string fullname2 = Request[“fullname”];
获取 HTTP 查询字符串变量集合。
RawUrl Request.RawUrl 获取当前请求的原始 URL。
ReadEntityBodyMode   获取指示请求实体是否被读以及如何被读的值。
RequestContext   获取当前请求的 RequestContext 实例。
RequestType sw.WriteLine(Server.HtmlEncode(Request.RequestType)); 获取或设置客户端使用的 HTTP 数据传输方法(GET 或 POST)。
ServerVariables NameValueCollection coll = Request.ServerVariables;
String[] arr1 = coll.AllKeys;
获取 Web 服务器变量的集合。
TimedOutToken   获取请求超时时去除的 CancellationToken 对象。
TotalBytes Request.TotalBytes 获取当前输入流中的字节数
Unvalidated   提供对 HTTP 请求值的访问权限,不触发请求验证。
Url Uri MyUrl = Request.Url; 获取有关当前请求的 URL 的信息。
UrlReferrer Uri MyUrl = Request.UrlReferrer; 获取有关客户端上次请求的 URL 的信息,该请求链接到当前的 URL。
UserAgent String userAgent = Request.UserAgent; 获取客户端浏览器的原始用户代理信息。
UserHostAddress sw.WriteLine(Server.HtmlEncode(Request.UserHostAddress)); 获取远程客户端的 IP 主机地址。
UserHostName sw.WriteLine(Server.HtmlEncode(Request.UserHostName)); 获取远程客户端的 DNS 名称。
UserLanguages String[] userLang = Request.UserLanguages; 获取客户端语言首选项的排序字符串数组。

方法:

名称 用法 说明
Abort Abort() 强制地终止基础 TCP 连接,会导致任何显著的 I/O 失败。
BinaryRead public byte[] BinaryRead(int count) 执行对当前输入流进行指定字节数的二进制读取。
Equals (Object) person1a.Equals(person1b));               确定指定的对象是否等于当前对象。
GetBufferedInputStream public Stream GetBufferedInputStream() 获取一个 Stream 对象,该对象可用于读取传入的 HTTP 实体主体。
GetBufferlessInputStream() public Stream GetBufferlessInputStream() 获取一个 Stream 对象,该对象可用于读取传入的 HTTP 实体主体。
GetBufferlessInputStream  (Boolean) public Stream GetBufferlessInputStream(
bool disableMaxRequestLength
)

获取能被用于读取正在到来的 HTTP 实体正文的 Stream 对象,

同时随意地禁止设置在 MaxRequestLength 属性中的请求长度限制。

GetHashCode public virtual int GetHashCode() 作为默认哈希函数。 (继承自 Object。)
GetType Object.GetType() 获取当前实例的 Type。 (继承自 Object。)
InsertEntityBody public void InsertEntityBody() 向 IIS 提供 HTTP 请求实体正文的副本。
InsertEntityBody(byte[], int, int) public void InsertEntityBody(byte[] buffer, int offset, int count) 向 IIS 提供 HTTP 请求实体正文的副本以及有关请求实体对象的信息。
MapImageCoordinates public int[] MapImageCoordinates(string imageFieldName) 将传入图像字段窗体参数映射为适当的 x 坐标值和 y 坐标值。
MapPath(string) public string MapPath(string virtualPath) 将指定的虚拟路径映射到物理路径。
MapPath(String, String, Boolean) public string MapPath(string virtualPath,string baseVirtualDir,bool allowCrossAppMapping) 将指定的虚拟路径映射到物理路径。
MapRawImageCoordinates public double[] MapRawImageCoordinates(string imageFieldName) 将传入图像字段窗体参数映射为适当的 x 和 y 坐标值。
SaveAs public void SaveAs(string filename,bool includeHeaders) 将 HTTP 请求保存到磁盘。
ToString Object obj = new Object();
Console.WriteLine(obj.ToString());
返回表示当前对象的字符串。 (继承自 Object。)
ValidateInput public void ValidateInput() 对通过 CookiesFormQueryString 属性访问的集合进行验证。
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,078
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,553
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,402
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,177
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,814
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898