如何解决错误消息:"无法映射路径'/'."

Tre*_*vor 157 c# asp.net iis

我在谷歌搜索和搜索过,我找不到任何看似适用于我的情况的东西,更不用说解决问题了.我试图导航到我的网站中的哪个地址并不重要(即使是不存在的地址也不会给出这个错误而不是404),我得到完全相同的消息(路径总是'/').有任何想法吗?

Server Error in '/' Application.

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: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[InvalidOperationException: Failed to map the path '/'.]
   System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +336

[HttpException (0x80004005): Failed to map the path '/'.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11556592
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4813333

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225
Run Code Online (Sandbox Code Playgroud)

更新:我在发布此内容后几分钟后回到了网站 - 没有对代码或配置进行任何更改 - 错误消失了.我真的很困惑,但它不再是一个问题.不确定应该对这个问题做些什么.

ker*_*rli 230

在我的情况下重启IIS解决了同样的问题.似乎在IIS中失败了.也不值得我恐慌.

IIS 7.5,顺便说一句.

  • 打开cmd提示符并运行'iisreset'.虽然听起来很平淡但却奏效了! (13认同)
  • +1帮助了我.是在我将"默认网站"重命名为其他名称后引起的.(在管理控制台中查找并启动IIS解决了它.) (8认同)
  • 用"iisreset"修复 (4认同)

小智 131

我在IIS 7下遇到了同样的问题(MVC 4).事实证明,App Pool身份没有对网站路径的正确授权.

  • 谢谢!重命名一个网站并得到错误,iisreset做了伎俩! (61认同)
  • 我也是.谢谢!为了进一步澄清,我最终将我的Web服务的应用程序池标识从"ApplicationPoolIdentity"更改为"Network Service". (15认同)
  • 转到IIS中树的最顶层,然后单击"重新启动"(在"管理服务器"下).使用IIS GUI修复了同样的问题. (13认同)
  • 对于我的情况,我只需要重置IIS :) (6认同)

Bra*_*ery 46

您不必重置IIS,只需回收应用程序池即可.


小智 27

今天,当我重命名托管我的MVC应用程序的默认网站时,我也开始收到该错误.但我重新启动了IIS,问题得到了解决.

  • 我有完全相同的问题 - 我在IIS中重命名了该网站,我开始收到此错误.回收应用程序池使其消失(当然,重新启动IIS会自动回收应用程序池).最奇怪的. (4认同)

Aja*_*707 5

我也有同样的问题。就我而言,我正在使用 InstalledSheild / InstalledAware 来设置 Web 服务。安装程序运行后出现上述错误,在解决问题时检查,发现安装程序运行后II的默认网站路径被删除。

所以我只是添加路径如下步骤。

  1. 转到命令提示符 -> 键入 InetMgr
  2. 打开 IIS,转到“默认网站”-> 高级设置(位于右侧菜单) 在此输入图像描述

  3. 转到物理路径并粘贴此内容 - '%SystemDrive%\inetpub\wwwroot' 如下 在此输入图像描述