URL 網址引數解析,取得網址引數 « 關於網路那些事...
阿新 • • 發佈:2018-12-23
ASP.NET C# URL 網址引數解析,取得網址引數
ASP.NET 提供許多 Request 屬性,可以對URL進行分析,取得網址引數
例如,這裡示範網址為:
底下分別列出解屬性及解析結果:
引數 | 結果 |
---|---|
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.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 |
如果你喜歡我們的文章內容,請在這裡按個讚
Tweet