元素 'system.webServer' 具有无效的子元素 'aspNetCore'

The element 'system.webServer' has invalid child element 'aspNetCore'

我在 Visual Studio 2015 年从其中一个模板创建了一个新的 ASP.NET Core MVC 6 应用程序。

我正在看的教程说要修改 web.config 文件。当我打开该文件时,Visual Studio 抛出警告:

Severity Code Description Project File Line Suppression State
Warning The element 'system.webServer' has invalid child element 'aspNetCore'. List of possible elements expected: 'asp, caching, cgi, defaultDocument, directoryBrowse, globalModules, handlers, httpCompression, webSocket, httpErrors, httpLogging, httpProtocol, httpRedirect, httpTracing, isapiFilters, modules, applicationInitialization, odbcLogging, security, serverRuntime, serverSideInclude, staticContent, tracing, urlCompression, validation, management, rewrite'.

这里是处女web.config文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
  -->

  <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>
</configuration>

如何消除警告?

安装.NET Core Tooling Preview 2 for Visual Studio 2015.

您可以从the .NET Downloads page

下载

如果它已经安装但无法运行,您可以尝试进行修复:转到 程序和功能、select Microsoft 。 NET Core 1.0.1 - VS 2015 Tooling Preview 2,单击更改,然后单击修复

同样的问题,我解决了运行 VS2016 "as administrator"。右键单击 VS2016 可执行文件,单击 "Run an Administrator" 然后加载项目

同样的问题在 VS 2015 中。我刚刚安装了 VS 2017 社区,这为我解决了这个问题。