.net 獲取當前網頁的的url


一、路徑獲取方法

如果測試的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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM