轉: http://www.cnblogs.com/pumaboyd/archive/2006/09/13/502820.html
ASP.NET中的路徑問題
| 這是我頁面請求連結http://localhost/MyWeb/Store/Page1.aspx?ddddd=9。下面是通過相應方法顯示的路徑,對比一下應該可以找到你想要的取得路徑的方法。 |
| Request.RawUrl |
| 原始 URL 定義為 URL 中域資訊之後的部分。在 URL 字串 http://www.contoso.com/articles/recent.aspx 中,原始 URL 為/articles/recent.aspx。原始 URL 包括查詢字串(如果存在)。 |
/MyWeb/Store/Page1.aspx?ddddd=9 |
| Request.Path |
| 當前請求的虛擬路徑。 |
/MyWeb/Store/Page1.aspx |
| Request.PathInfo |
| 對於URL Http://www.contoso.com/virdir/page.html/tail,PathInfo 值為/tail。 |
|
| Request.CurrentExecutionFilePath 和 Request.FilePath |
| CurrentExecutionFilePath 在重新導向方案(如 Execute 和 Transfer)中返回當前所執行頁的正確檔案路徑。當用戶端重新導向到另一頁時,FilePath 將返回初始頁的路徑;CurrentExecutionFilePath 返回子頁的路徑。 |
/MyWeb/Store/Page1.aspx |
| Request.PhysicalApplicationPath |
| 擷取當前正在執行的伺服器應用程式的根目錄的物理檔案系統路徑。(應用程式的跟目錄) |
k:/MyWeb/MyWeb/ |
| Request.PhysicalPath |
| 擷取與請求的 URL 相對應的物理檔案系統路徑。 |
k:/MyWeb/MyWeb/Store/Page1.aspx |
| Request.ApplicationPath |
| 擷取伺服器上 ASP.NET 應用程式的虛擬應用程式根路徑。 |
/MyWeb |
| AppDomain.CurrentDomain.BaseDirectory |
| 擷取基目錄,它由程式集衝突解決程式用來探測程式集。 |
k:/MyWeb/MyWeb/ |
| AppDomain.CurrentDomain.RelativeSearchPath |
| 擷取相對於基目錄的路徑,在此程式集衝突解決程式應探測專用程式集。 |
Bin |
| Assembly.CodeBase |
| 擷取最初指定的程式集的位置 |
file:///k:/MyWeb/MyWeb/bin/MyWeb.DLL |
| Assembly.Location |
| 如果包含清單的已負載檔案沒有被影像複製,則擷取該檔案的基本代碼格式的位置。 |
c:/windows/microsoft.net/framework/v1.1.4322/temporary asp.net files/myweb/a6aa4523/7564b5f7/assembly/dl2/19cb75f7/002a8314_c272c601/myweb.dll |
| Request.Server.MapPath() |
| 將指定的虛擬路徑映射到實體路徑。 |
|