方法如下:
Request.Url.ToString()獲取完整url(協議名+域名+站點名+文件名+參數):https://localhost:44300/WebForm1.aspx?abc=123 Request.RawUrl獲取客戶端請求的URL信息(不包括主機和端口):/WebForm1.aspx?abc=123 Request.Url.AbsolutePath獲取站點名+頁面名:/WebForm1.aspx Request.Url.Host獲取主機部分:localhost Request.Url.Query獲取參數部分:?abc=123 Request.ApplicationPath獲取應用程序的虛擬應用程序根路徑:/ Request.CurrentExecutionFilePath獲取當前請求的虛擬路徑:/WebForm1.aspx Request.Path獲取當前請求的虛擬路徑:/WebForm1.aspx Request.PathInfo獲取具有URL擴展名的資源的附加路徑信息: Request.PhysicalPath獲取與請求的URL相對應的物理文件系統路徑:c:\users\jim\documents\visual studio 2010\Projects\WebApplication3\WebApplication3\WebForm1.aspx Request.Url.LocalPath獲取文件名的本地操作系統表示形式:/WebForm1.aspx Request.Url.AbsoluteUri獲取絕對URL:https://localhost:44300/WebForm1.aspx?abc=123 Request.ServerVariables.Get("Local_Addr")獲取服務器IP:::1 Request.Url.Port獲取服務器端口:44300 Request.Url.Scheme獲取服務器協議頭:https