1

Visual Studio で ASP.Net Web サイト ソリューションを使用していますが、これを実行しようとするServer.MapPath(@"\");と、次のエラーが表示されます。この質問が以前に尋ねられたことは知っていますが、私にとって有効な解決策はまだ見つかっていません。どんなアイデアでも素晴らしいでしょう。

Failed to map the path '/'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Failed to map the path '/'.

Source Error: 


Line 10:     protected void Page_Load(object sender, EventArgs e)
Line 11:     {
Line 12:       string directory = Server.MapPath(@"\");
Line 13:       Response.Write(directory);
Line 14:     }

Source File: c:\Users\Josh\Documents\Visual Studio 2010\WebSites\MMCR\About.aspx.cs    Line: 12 

Stack Trace: 


[InvalidOperationException: Failed to map the path '/'.]
   System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) +8937646
   System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath) +42
   System.Web.VirtualPath.MapPathInternal() +4
   System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping) +107
   System.Web.HttpRequest.MapPath(VirtualPath virtualPath) +37
   System.Web.HttpServerUtility.MapPath(String path) +99
   About.Page_Load(Object sender, EventArgs e) in c:\Users\Josh\Documents\Visual Studio 2010\WebSites\MMCR\About.aspx.cs:12
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
4

3 に答える 3

5

他のすべてが解決策を提案した場合、機能しない場合は、Visual Studio に管理者特権がないことを意味します。

したがって、Visual Studio の「管理者として実行」を実行して、もう一度実行を試みることができます。

于 2013-03-09T04:01:14.097 に答える
3

これを試して:

Server.mapPath("~/");
于 2013-03-09T03:52:18.763 に答える
0

ここに回答がない場合エラー メッセージの解決方法: 「パス '/' のマッピングに失敗しました。」助けて、試してくださいServer.MapPath(@".\");。これとあなたのコードは私にとってはうまくいき、同じ結果が得られました。

于 2013-03-09T03:53:32.600 に答える