一、路徑獲取方法
如果測試的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