ASP.NET Windows 10 Fall Creators Update 后的 HttpHandler 错误

ASP.NET HttpHandler error after Windows 10 Fall Creators Update

几天前,我的 Windows 10 开发机获得了 Falls Creators Update。

从那时起,每次尝试在任何 ASP.NET 网站(not 网络应用程序)中注册自定义 HttpHandler 都会失败,并出现错误:

Failed to map the path '/App_GlobalResources/'.

堆栈跟踪是:

[InvalidOperationException: Failed to map the path '/App_GlobalResources/'.] 
System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, 
Boolean permitNull) +8965114
System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath) +42

System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDate2
(StandardDiskBuildResultCache diskCache) +295


System.Web.Compilation.BuildManager.CheckTopLevelFilesUpToDate
(StandardDiskBuildResultCache diskCache) +55
System.Web.Compilation.BuildManager.RegularAppRuntimeModeInitialize() +174
System.Web.Compilation.BuildManager.Initialize() +238
System.Web.Compilation.BuildManager.InitializeBuildManager() +267
System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags) +224

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

我正在使用集成 IIS Express 的 Visual Studio 2015。我有一些旧的 asp.net 网站(.net 2.0 版)曾经有效。现在,即使是下面的例子也不起作用:

App_Code/MyHandler.cs:

public class MyHandler : IHttpHandler
{
    public MyHandler()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/html";
        context.Response.Write("Hello");
    }
}

web.config:

<?xml version="1.0"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="MyHandler" verb="*" path="*.htm" type="MyHandler"/>
    </handlers>
  </system.webServer>
</configuration>

我真的无法理解发生了什么,我 运行 失去了想法和耐心。请帮忙。 TIA.

我决定听从@Hamlet Hakobyan 的建议并卸载 Windows 10 Fall Creators Update。

让我马上告诉你,问题现在已经解决了。

这是我的开发设置,以防有人遇到同样的情况:

  • Windows 10 build 1709(秋季创作者更新)
  • Visual Studio 社区 2015 更新 3
  • ASP.NET 网站项目(不是 网络应用程序项目)
  • .NET 框架版本 2.0
  • IHttpHandlerApp_Code 文件夹中的 .cs 文件中实现。
  • 在集成模式下 web.config 中为 IIS Express 运行 注册 Http 处理程序:https://msdn.microsoft.com/en-us/library/46c5ddfy.aspx

如果您的 http 处理程序在安装 Windows 10 Fall Creators Update 后停止工作并且您收到以下不太有用的错误:

Failed to map the path '/App_GlobalResources/'.

然后继续并恢复到之前的 Windows 10 build (1703)。

希望对您有所帮助。