ASP.NET中Request.ApplicationPath、Request.FilePath、Request.Path、.Request.MapPath


1.Request.ApplicationPath->當前應用的目錄 

2.Request.FilePath->對應於iis的虛擬目錄 
  如 URL http://mockte.com/1/index.html/pathinfo 
  FilePath = /1/index.html 

3.Request.Path->當前請求的虛擬路徑 
  Path 是 FilePath 和 PathInfo 尾部的串聯。例如 URL http://mockte.com/1/index.html/pathinfo 
  那么Path = /1/index.html/pathinfo 

4.Request.MapPath(string url)->將url映射為iis上的虛擬目錄 
  這個目錄都是相對於application的根目錄的 
  於Server.MapPath相比,不會包含類似c:/這樣的路徑 
  可以理解為是相對路徑(對比的Server.MapPath就是絕對路徑) 

5.Server.MapPath(string url)->將url映射為服務器上的物理路徑 
  例如 http://mockte.com/1/index.html  假設你的應用程序在c:/iis/MySite中 
  那么就是 c:/iis/MySite/1/index.html

6.底下這張表就是根據Browser Request 的網址相關的屬性的用法

網址:http://localhost:1897/News/Press/Content.aspx/123?id=1#toc
Request.ApplicationPath /
Request.PhysicalPath D:/Projects/Solution/web/News/Press/Content.aspx
System.IO.Path.GetDirectoryName(Request.PhysicalPath) D:/Projects/Solution/web/News/Press
Request.PhysicalApplicationPath D:/Projects/Solution/web/
System.IO.Path.GetFileName(Request.PhysicalPath) Content.aspx
Request.CurrentExecutionFilePath /News/Press/Content.aspx
Request.FilePath /News/Press/Content.aspx
Request.Path /News/Press/Content.aspx/123
Request.RawUrl /News/Press/Content.aspx/123?id=1
Request.Url.AbsolutePath /News/Press/Content.aspx/123
Request.Url.AbsoluteUri http://localhost:1897/News/Press/Content.aspx/123?id=1
Request.Url.Scheme http
Request.Url.Host localhost
Request.Url.Port 1897
Request.Url.Authority localhost:1897
Request.Url.LocalPath /News/Press/Content.aspx/123
Request.PathInfo /123
Request.Url.PathAndQuery /News/Press/Content.aspx/123?id=1
Request.Url.Query ?id=1
Request.Url.Fragment  
Request.Url.Segments /
News/
Press/
Content.aspx/
123


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM