从 VS 2015 启动的 IIS Express 无法读取包含 <aspNetCore> 元素的配置文件

IIS Express launched from VS 2015 cannot read config file with <aspNetCore> element

我正在尝试从现有代码(最初在 VS Code 中创建,运行 从命令线)。

在我的 web.config 文件中,我有以下块:

<system.webServer>
  <handlers>
    <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
  </handlers>
  <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
</system.webServer>

Visual Studio 2015(更新 3)给 <aspNetCore> 元素一个波浪形下划线,并表示该元素不能是 <handlers> 的子元素。当我启动网站时,出现以下错误。

HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information: Module IIS Web Core Notification
Unknown Handler Not yet determined Error Code 0x8007000d Config Error Config File
\?\C:\Users\ktsashes\Projects\aspnet-proj\web.config

如果我删除该行,IIS Express 会抱怨错误“处理程序 "aspNetCore" 在其模块列表 中有一个错误的模块 "AspNetCoreModule"”。如果我删除整个块,它不会通过 ASP.Net 并尝试列出目录(这是安全规则禁止的)。

大多数故障排除步骤都说我应该安装 URL Rewrite 模块,但那是针对 IIS 的,我了解到它不适用于 IIS Express。但无论如何我都尝试安装它,但没有成功。

我在 Documents/IISExpress/Logs 的日志似乎没有任何有用的信息。我该如何进一步解决或补救此问题?

也许这是个愚蠢的问题,但您是否尝试过安装 .NET Core 1.0.0 - VS 2015 Tooling Preview 2 https://www.microsoft.com/net/core#windows

如果是这样,也许可以尝试修复它:

  1. 转到程序和功能
  2. Select Microsoft .NET Core 1.0.0 - VS 2015 工具预览版 2
  3. 点击更改
  4. 选择修复

我的问题是我的项目没有引用“.NETCoreApp”。我也无法将它添加到我使用这些文件创建的项目中。我能够让它工作的唯一方法是创建一个新项目并将所有文件复制过来。这对 git mv 来说有点麻烦,但现在似乎一切正常。因此,请仔细检查您的项目中是否有“.NETCoreApp”引用。