ASP.NET C# URL 網址參數解析,取得網址參數
ASP.NET 提供許多 Request 屬性,可以對URL進行分析,取得網址參數
例如,這裡示範網址為:
https://my.url.com:8080/Detail/Page/List.aspx/showmore?mid=20#main
- 底下分別列出解屬性及解析結果
參數 | 結果 |
---|---|
Request.ApplicationPath | / |
Request.Url.Host | my.url.com |
Request.Url.Port | 8080 |
Request.Url.Scheme | https |
Request.Url.Authority | my.url.com:8080 |
Request.Path | /Detail/Page/List.aspx/showmore |
Request.Url.LocalPath | /Detail/Page/List.aspx/showmore |
Request.PathInfo | /showmore |
Request.Url.Query | ?mid=20 |
Request.CurrentExecutionFilePath | /Detail/Page/List.aspx |
Request.FilePath | /Detail/Page/List.aspx |
Request.RawUrl | /Detail/Page/List.aspx/showmore?mid=20 |
Request.Url.PathAndQuery | /Detail/Page/List.aspx/showmore?mid=20 |
Request.Url.AbsoluteUri | https://my.url.com:8080/Detail/Page/List.aspx/showmore?mid=20 |
Request.Url.AbsolutePath | /Detail/Page/List.aspx/showmore |
- 取得系統路徑
參數 | 結果 |
---|---|
Request.PhysicalPath | C:\wwwroot\Detail\Page\List.aspx |
System.IO.Path.GetDirectoryName(Request.PhysicalPath) | C:\wwwroot\Detail\Page |
Request.PhysicalApplicationPath | C:\wwwroot\ |
System.IO.Path.GetFileName(Request.PhysicalPath) | List.aspx |
- 解析參數
參數 | 結果 |
---|---|
Request.Url.Segments | /, Detail/, Page/, List.aspx/, showmore |
沒有留言:
張貼留言