「マイクロソフト系技術情報 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。
Webサイトの様々なパスを取得する方法。
仮想パスに対応する物理ファイル パス
Server組み込みオブジェクトからHttpServerUtility?インスタンスを取得。
string path = Server.MapPath("./");
HttpContext?.Current.ServerプロパティからHttpServerUtility?インスタンスを取得。
string path = HttpContext.Current.Server.MapPath("./");
https://msdn.microsoft.com/ja-jp/library/system.web.httprequest.physicalapplicationpath.aspx
サーバー アプリケーションのルート ディレクトリの物理ファイル システム パス
https://msdn.microsoft.com/ja-jp/library/system.web.httprequest.physicalpath.aspx
要求された URL に一致する物理ファイル システム パス
https://msdn.microsoft.com/ja-jp/library/system.web.httprequest.applicationpath.aspx
現在のアプリケーションのルート仮想パス(「/」や「/アプリ名」のような)。
https://msdn.microsoft.com/ja-jp/library/system.web.httprequest.currentexecutionfilepath.aspx
現在の要求の仮想パス(Transfer または Executeを反映)
https://msdn.microsoft.com/ja-jp/library/system.web.httprequest.filepath.aspx
現在の要求の仮想パス(Transfer または Executeを反映しない)
https://msdn.microsoft.com/ja-jp/library/system.web.httprequest.path.aspx
現在の要求の仮想パス(URL 拡張子付きリソースに追加パス情報を反映)