針對 `Request.Url`、`Request.RawUrl` 等屬性,以實例網址 `https://www.example.com/app/page.aspx?id=1&name=test` 逐一對照輸出值,方便快速查閱。
| 屬性/方法 | 回傳值 | 說明 |
|---|---|---|
Request.Url.ToString() | `https://www.example.com/app/page.aspx?id=1&name=test` | 完整 URL (含 QueryString) |
Request.RawUrl | `/app/page.aspx?id=1&name=test` | 相對根目錄的路徑 + QueryString |
Request.Url.PathAndQuery | `/app/page.aspx?id=1&name=test` | 同 RawUrl |
Request.Url.AbsolutePath | `/app/page.aspx` | 相對根目錄的路徑 (不含 QueryString) |
Request.Path | `/app/page.aspx` | 同 AbsolutePath |
Request.CurrentExecutionFilePath | `/app/page.aspx` | 執行中檔案虛擬路徑 (Server.Transfer 後不同) |
Request.ApplicationPath | `/app` | 應用程式虛擬根路徑 |
Request.Url.Host | `www.example.com` | 主機名 (不含 Port) |
Request.Url.Authority | `www.example.com:80` | 主機 + Port |
Request.Url.Scheme | `http` | 協定 |
Request.Url.Port | `80` | Port 號 |
Request.Url.Query | `?id=1&name=test` | QueryString (含前導 ?) |
Request.QueryString["id"] | `1` | 解析後的參數值 |
Request.Url.Fragment | `""` | 片段識別符 (# 後內容) |
Request.PhysicalPath | `C:\Webs\MyApp\page.aspx` | 伺服器實體檔案路徑 |
Request.Url.LocalPath | `/app/page.aspx` | 同 AbsolutePath |
Request.Url.AbsoluteUri | `https://www.example.com/app/page.aspx?id=1&name=test` | 同 ToString() |
Request.PathInfo | `""` | 路徑資訊 (如 `/page.aspx/extra` 中的 `/extra`) |
`Request.Path`、`Request.CurrentExecutionFilePath`、`Request.Url.AbsolutePath` 會反映目標頁面路徑,但 `Request.RawUrl`、`Request.Url.PathAndQuery` 保持原始請求路徑。