1.Request.ApplicationPath->當前應用的目錄? ? Jsp中, ApplicationPath指的是當前的application(應用程序)的目錄,ASP.NET中也是這個意思。? ? 對應的--例如我的服務器上有兩個web應用域名都是mockte.com 一個映射到目錄mockte.com/1/ 另一個影射到 http://mockte.com/2/ ? 那么mockte.com/1/就是第一個應用的ApplicationPath 同理 mockte.com/2/就是第二個應用的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
?
底下這張表就是各種跟 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 |