Request对象的各种路径属性
1.Path:当前请求的虚拟路径;
2.Url:有关当前请求的Url信息,为URI类型;
示例:
在Request/WebForm1.aspx页面中添加一链接,链接地址为“WebForm2.aspx?type=test”,那么在WebForm2.aspx.cs的Form_Load方法中监控到的Request各属性值如下表所示
属性 | 监视到的取值 | msdn上的说明 |
Request.ApplicationPath | / | 获取服务器上 ASP.NET 应用程序的虚拟应用程序根路径。 |
Request.AppRelativeCurrentExecutionFilePath | ~/Request/WebForm2.aspx | 获取应用程序根的虚拟路径,并通过对应用程序根使用波形符 (~) 表示法(例如,以“~/page.aspx”的形式)使该路径成为相对路径。 |
Request.CurrentExecutionFilePath | /Request/WebForm2.aspx | 获取当前请求的虚拟路径。 |
Request.CurrentExecutionFilePathExtension | .aspx | |
Request.FilePath | /Request/WebForm2.aspx | 获取当前请求的虚拟路径。 |
Request.Path | /Request/WebForm2.aspx | 获取当前请求的虚拟路径。 |
Request.PathInfo | 获取具有 URL 扩展名的资源的附加路径信息。 | |
Request.PhysicalApplicationPath | D:\project\EasyFramework\Framework\EasyFramework.Web\ | 获取当前正在执行的服务器应用程序的根目录的物理文件系统路径。 |
Request.PhysicalPath | D:\project\EasyFramework\Framework\EasyFramework.Web\Request\WebForm2.aspx | 获取与请求的 URL 相对应的物理文件系统路径。 |
Request.RawUrl | /Request/WebForm2.aspx?type=test | 获取当前请求的原始 URL。 |
Request.UrlReferrer.AbsolutePath | /Request/WebForm1.aspx | 获取有关客户端上次请求的 URL 的信息 |
Request.UrlReferrer.PathAndQuery | /Request/WebForm1.aspx | |
Request.Url.AbsolutePath | /Request/WebForm2.aspx | 获取 URI 的绝对路径。 |
Request.Url.AbsoluteUri | http://localhost:42053/Request/WebForm2.aspx?type=test | 获取绝对 URI。 |
Request.Url.Host | localhost | 获取此实例的主机部分。 |
Request.Url.HostNameType | Dns | 获取 URI 中指定的主机名的类型。 |
Request.Url.LocalPath | /Request/WebForm2.aspx | 获取文件名的本地操作系统表示形式。 |
Request.Url.OriginalString | http://localhost:42053/Request/WebForm2.aspx?type=test | 获取传递给 Uri 构造函数的原始 URI 字符串。 |
Request.Url.PathAndQuery | /Request/WebForm2.aspx?type=test | 获取用问号 (?) 分隔的 AbsolutePath 和 Query 属性。 |
Request.Url.Port | 42053 | 获取此 URI 的端口号。 |
Request.Url.Query | ?type=test | 获取指定 URI 中包括的任何查询信息。 |
Request.Url.UserInfo | 获取用户名、密码或其他与指定 URI 关联的特定于用户的信息。 |