一、路径获取方法
如果测试的url地址是http://www.test.com/testweb/default.aspx 通过ASP.NET获取结果如下:
Request.ApplicationPath: /testweb
Request.CurrentExecutionFilePath: /testweb/default.aspx
Request.FilePath: /testweb/default.aspx
Request.Path: /testweb/default.aspx
Request.PhysicalApplicationPath: E:\WWW\testweb
Request.PhysicalPath: E:\WWW\testweb\default.aspx
Request.RawUrl: /testweb/default.aspx
Request.Url.AbsolutePath: /testweb/default.aspx
Request.Url.AbsoluteUri: http://www.test.com/testweb/default.aspx
Request.Url.Host: www.test.com
Request.Url.LocalPath: /testweb/default.aspx
2020-6-18更新
二、Request.Url和Request.RawUrl详解
Request.Url 获取静态地址
如果测试的静态地址是Url:https://www.test.web/zt/210662/zq.html,而它对应的实际web目录是https://www.test.web/zt/spacepage.aspx
通过ASP.NET获取结果如下:
Request.Url: https://www.test.web/zt/spacepage.aspx
Request.RawUrl: /zt/210662/zq.html
Request.Url.AbsoluteUri: https://www.test.web/zt/spacepage.aspx
Request.Url.AbsolutePath: /zt/spacepage.aspx
Request.Url获取的地址并不是 https://www.test.web/zt/210662/zq.html