1. 首頁
  2. »
  3. 網頁開發
  4. »
  5. ASP.NET
  6. »
  7. [.NET]Request.URL取得網址中的參數

[.NET]Request.URL取得網址中的參數

2008/12/20

  以前常用Request.Pash去讀取網址後的參數,但每次要用時上網都找的半死,甘脆把它分享出來,一邊幫自已作筆記外,另一方面也給有需要的朋友們,梅干桑個人覺得還蠻不錯用的。


網址:http://localhost/minwt/doc/detail.aspx/123?id=1#top
語 法 結 果
Request.ApplicationPath /
Request.PhysicalPath D:\Projects\Solution\web\minwt\doc\detail.aspx
System.IO.Path.GetDirectoryName
(Request.PhysicalPath)
D:\Projects\Solution\web\minwt\doc
Request.PhysicalApplicationPath D:\Projects\Solution\web</strong>
System.IO.Path.GetFileName
(Request.PhysicalPath)
detail.aspx
Request.CurrentExecutionFilePath /minwt/doc/detail.aspx
Request.FilePath /minwt/doc/detail.aspx
Request.Path /minwt/doc/detail.aspx/123
Request.RawUrl /minwt/doc/detail.aspx/123?id=1
Request.Url.AbsolutePath /minwt/doc/detail.aspx/123
Request.Url.AbsoluteUri http://localhost/minwt/doc/detail.aspx/123?id=1
Request.Url.Scheme http
Request.Url.Host localhost
Request.Url.Port 1897
Request.Url.Authority localhost:1897
Request.Url.LocalPath /minwt/doc/detail.aspx/123
Request.PathInfo /123
Request.Url.PathAndQuery /minwt/doc/detail.aspx/123?id=1
Request.Url.Query ?id=1
Request.Url.Segments /
minwt/
doc/
detail.aspx/
123