1.简单的环境搭建
在本地IIS上配置了一个网站:主机名为wjnhome.com,端口88,然后建了一个虚拟目录指向同一站点,虚拟目录名称为virtual,配置host为127.0.0.1 wjnhome.com
所以地址就为:http://jb51.net:88/virtual/urldemo.aspx?id=2#top
2.编写简单的代码
复制代码 代码如下:
//虚拟目录的路径
Response.Write("<strong>Request.ApplicationPath:</strong>" + Request.ApplicationPath + "</br>");
//站点的物理路径(完整路径)
Response.Write("<strong>Request.PhysicalPath:</strong>" + Request.PhysicalPath + "</br>");
//站点物理路径的目录
Response.Write("<strong>DirectoryName:</strong>" + System.IO.Path.GetDirectoryName(Request.PhysicalPath) + "</br>");
//站点物理路径的目录
Response.Write("<strong>Request.PhysicalApplicationPath:</strong>" + Request.PhysicalApplicationPath + "</br>");
//当前页面的文件名
Response.Write("<strong>FileName:</strong>" + System.IO.Path.GetFileName(Request.PhysicalPath) + "</br>");
//当前页面的虚拟路径
Response.Write("<strong>Request.CurrentExecutionFilePath:</strong>" + Request.CurrentExecutionFilePath + "</br>");
//当前页面的虚拟路径
Response.Write("<strong>Request.FilePath:</strong>" + Request.FilePath + "</br>");
Response.Write("<strong>Request.Path:</strong>" + Request.Path + "</br>");
//原始URL
Response.Write("<strong>Request.RawUrl:</strong>" + Request.RawUrl + "</br>");
//绝对路径(不包括参数什么的)
Response.Write("<strong>Request.Url.AbsolutePath:</strong>" + Request.Url.AbsolutePath + "</br>");
//绝对URL
Response.Write("<strong>Request.Url.AbsoluteUri:</strong>" + Request.Url.AbsoluteUri + "</br>");
//URL协议方案
Response.Write("<strong>Request.Url.Scheme:</strong>" + Request.Url.Scheme + "</br>");
//URL的主机名
Response.Write("<strong>Request.Url.Host:</strong>" + Request.Url.Host + "</br>");
//URL端口号
Response.Write("<strong>Request.Url.Port:</strong>" + Request.Url.Port + "</br>");
//主机名+端口号
Response.Write("<strong>Request.Url.Authority:</strong>" + Request.Url.Authority + "</br>");
//获取文件名的本地操作系统表现形式
Response.Write("<strong>Request.Url.LocalPath:</strong>" + Request.Url.LocalPath + "</br>");
//附加路径信息,例如http://jb51.net:88/UrlDemo.aspx/Hello?id=22#top 那么这里就是Hello
Response.Write("<strong>Request.PathInfo:</strong>" + Request.PathInfo + "</br>");
//URL的路径和GET参数
Response.Write("<strong>Request.Url.PathAndQuery:</strong>" + Request.Url.PathAndQuery + "</br>");
//URL的GET参数
Response.Write("<strong>Request.Url.Query:</strong>" + Request.Url.Query + "</br>");
//主要指的是http://jb51.net:88/UrlDemo.aspx/Hello?id=22#top中#后面的top。
//但一般情况下无法获取值,因为浏览器不会把这个值发送到服务器端
Response.Write("<strong>Request.Url.Fragment:</strong>" + Request.Url.Fragment + "</br>");
//主机名
Response.Write("<strong>Request.Url.DnsSafeHost:</strong>" + Request.Url.DnsSafeHost + "</br>");
//URL的全部
Response.Write("<strong>Request.Url.OriginalString:</strong>" + Request.Url.OriginalString + "</br>");
//这种情况 Uri uriAddress = new Uri ("http://user:password@www.contoso.com/index.htm ") Console.WriteLine(uriAddress.UserInfo);
Response.Write("<strong>Request.Url.UserInfo:</strong>" + Request.Url.UserInfo + "</br>");
//从某个页面跳转过来的时候会显示源页面的值
Response.Write("<strong>Request.UrlReferrer:</strong>" + Request.UrlReferrer + "</br>");
//URI的每一段
for (var i = 0; i < Request.Url.Segments.Length;i++ )
{
Response.Write("<strong>Request.Url.Segment" + i + ":</strong>" + Request.Url.Segments[i] + "</br>");
}
3.输出结果
Request.ApplicationPath:/virtual
Request.PhysicalPath:E:\VsProject\201200420\UrlDemo\UrlDemo\urldemo.aspx
DirectoryName:E:\VsProject\201200420\UrlDemo\UrlDemo
Request.PhysicalApplicationPath:E:\VsProject\201200420\UrlDemo\UrlDemo\
FileName:urldemo.aspx
Request.CurrentExecutionFilePath:/virtual/urldemo.aspx
Request.FilePath:/virtual/urldemo.aspx
Request.Path:/virtual/urldemo.aspx
Request.RawUrl:/virtual/urldemo.aspx?id=2
Request.Url.AbsolutePath:/virtual/urldemo.aspx
Request.Url.AbsoluteUri:http://jb51.net:88/virtual/urldemo.aspx?id=2
Request.Url.Scheme:http
Request.Url.Host:wjnhome.com
Request.Url.Port:88
Request.Url.Authority:wjnhome.com:88
Request.Url.LocalPath:/virtual/urldemo.aspx
Request.PathInfo:
Request.Url.PathAndQuery:/virtual/urldemo.aspx?id=2
Request.Url.Query:?id=2
Request.Url.Fragment:
Request.Url.DnsSafeHost:wjnhome.com
Request.Url.OriginalString:http://jb51.net:88/virtual/urldemo.aspx?id=2
Request.Url.UserInfo:
Request.UrlReferrer:
Request.Url.Segment0:/
Request.Url.Segment1:virtual/
Request.Url.Segment2:urldemo.aspx
作者:wjn
在本地IIS上配置了一个网站:主机名为wjnhome.com,端口88,然后建了一个虚拟目录指向同一站点,虚拟目录名称为virtual,配置host为127.0.0.1 wjnhome.com
所以地址就为:http://jb51.net:88/virtual/urldemo.aspx?id=2#top
2.编写简单的代码
复制代码 代码如下:
//虚拟目录的路径
Response.Write("<strong>Request.ApplicationPath:</strong>" + Request.ApplicationPath + "</br>");
//站点的物理路径(完整路径)
Response.Write("<strong>Request.PhysicalPath:</strong>" + Request.PhysicalPath + "</br>");
//站点物理路径的目录
Response.Write("<strong>DirectoryName:</strong>" + System.IO.Path.GetDirectoryName(Request.PhysicalPath) + "</br>");
//站点物理路径的目录
Response.Write("<strong>Request.PhysicalApplicationPath:</strong>" + Request.PhysicalApplicationPath + "</br>");
//当前页面的文件名
Response.Write("<strong>FileName:</strong>" + System.IO.Path.GetFileName(Request.PhysicalPath) + "</br>");
//当前页面的虚拟路径
Response.Write("<strong>Request.CurrentExecutionFilePath:</strong>" + Request.CurrentExecutionFilePath + "</br>");
//当前页面的虚拟路径
Response.Write("<strong>Request.FilePath:</strong>" + Request.FilePath + "</br>");
Response.Write("<strong>Request.Path:</strong>" + Request.Path + "</br>");
//原始URL
Response.Write("<strong>Request.RawUrl:</strong>" + Request.RawUrl + "</br>");
//绝对路径(不包括参数什么的)
Response.Write("<strong>Request.Url.AbsolutePath:</strong>" + Request.Url.AbsolutePath + "</br>");
//绝对URL
Response.Write("<strong>Request.Url.AbsoluteUri:</strong>" + Request.Url.AbsoluteUri + "</br>");
//URL协议方案
Response.Write("<strong>Request.Url.Scheme:</strong>" + Request.Url.Scheme + "</br>");
//URL的主机名
Response.Write("<strong>Request.Url.Host:</strong>" + Request.Url.Host + "</br>");
//URL端口号
Response.Write("<strong>Request.Url.Port:</strong>" + Request.Url.Port + "</br>");
//主机名+端口号
Response.Write("<strong>Request.Url.Authority:</strong>" + Request.Url.Authority + "</br>");
//获取文件名的本地操作系统表现形式
Response.Write("<strong>Request.Url.LocalPath:</strong>" + Request.Url.LocalPath + "</br>");
//附加路径信息,例如http://jb51.net:88/UrlDemo.aspx/Hello?id=22#top 那么这里就是Hello
Response.Write("<strong>Request.PathInfo:</strong>" + Request.PathInfo + "</br>");
//URL的路径和GET参数
Response.Write("<strong>Request.Url.PathAndQuery:</strong>" + Request.Url.PathAndQuery + "</br>");
//URL的GET参数
Response.Write("<strong>Request.Url.Query:</strong>" + Request.Url.Query + "</br>");
//主要指的是http://jb51.net:88/UrlDemo.aspx/Hello?id=22#top中#后面的top。
//但一般情况下无法获取值,因为浏览器不会把这个值发送到服务器端
Response.Write("<strong>Request.Url.Fragment:</strong>" + Request.Url.Fragment + "</br>");
//主机名
Response.Write("<strong>Request.Url.DnsSafeHost:</strong>" + Request.Url.DnsSafeHost + "</br>");
//URL的全部
Response.Write("<strong>Request.Url.OriginalString:</strong>" + Request.Url.OriginalString + "</br>");
//这种情况 Uri uriAddress = new Uri ("http://user:password@www.contoso.com/index.htm ") Console.WriteLine(uriAddress.UserInfo);
Response.Write("<strong>Request.Url.UserInfo:</strong>" + Request.Url.UserInfo + "</br>");
//从某个页面跳转过来的时候会显示源页面的值
Response.Write("<strong>Request.UrlReferrer:</strong>" + Request.UrlReferrer + "</br>");
//URI的每一段
for (var i = 0; i < Request.Url.Segments.Length;i++ )
{
Response.Write("<strong>Request.Url.Segment" + i + ":</strong>" + Request.Url.Segments[i] + "</br>");
}
3.输出结果
Request.ApplicationPath:/virtual
Request.PhysicalPath:E:\VsProject\201200420\UrlDemo\UrlDemo\urldemo.aspx
DirectoryName:E:\VsProject\201200420\UrlDemo\UrlDemo
Request.PhysicalApplicationPath:E:\VsProject\201200420\UrlDemo\UrlDemo\
FileName:urldemo.aspx
Request.CurrentExecutionFilePath:/virtual/urldemo.aspx
Request.FilePath:/virtual/urldemo.aspx
Request.Path:/virtual/urldemo.aspx
Request.RawUrl:/virtual/urldemo.aspx?id=2
Request.Url.AbsolutePath:/virtual/urldemo.aspx
Request.Url.AbsoluteUri:http://jb51.net:88/virtual/urldemo.aspx?id=2
Request.Url.Scheme:http
Request.Url.Host:wjnhome.com
Request.Url.Port:88
Request.Url.Authority:wjnhome.com:88
Request.Url.LocalPath:/virtual/urldemo.aspx
Request.PathInfo:
Request.Url.PathAndQuery:/virtual/urldemo.aspx?id=2
Request.Url.Query:?id=2
Request.Url.Fragment:
Request.Url.DnsSafeHost:wjnhome.com
Request.Url.OriginalString:http://jb51.net:88/virtual/urldemo.aspx?id=2
Request.Url.UserInfo:
Request.UrlReferrer:
Request.Url.Segment0:/
Request.Url.Segment1:virtual/
Request.Url.Segment2:urldemo.aspx
作者:wjn
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年11月18日
2024年11月18日
- 杨泰瑞《City Boy》[320K/MP3][28.71MB]
- 胡彦斌《失业情歌》首版[WAV+CUE]
- 杨泰瑞《City Boy》[FLAC/分轨][159.66MB]
- APM亚流新世代《一起冒险》[320K/MP3][68.66MB]
- FIM《天伦乐》(DaydreamsAndLullabies)24K金碟[WAV+CUE]
- 【雨果唱片】中国管弦乐《鹿回头》
- 【雨果唱片】中国管弦乐《鹿回头》WAV
- APM亚流新世代《一起冒险》[FLAC/分轨][106.77MB]
- 崔健《飞狗》律冻文化[WAV+CUE][1.1G]
- 罗志祥《舞状元 (Explicit)》[320K/MP3][66.77MB]
- 尤雅.1997-幽雅精粹2CD【南方】【WAV+CUE】
- 张惠妹.2007-STAR(引进版)【EMI百代】【WAV+CUE】
- 群星.2008-LOVE情歌集VOL.8【正东】【WAV+CUE】
- 罗志祥《舞状元 (Explicit)》[FLAC/分轨][360.76MB]
- Tank《我不伟大,至少我能改变我。》[320K/MP3][160.41MB]