ASP.NET 发布到 IIS 时找不到核心页面

ASP.NET Core page not found when publishing to IIS

我将 ASP.NET 核心项目从 RC1 更新到 1.0 RTM(使用预览版 2 工具),一切顺利。我可以毫无问题地在 Visual Studio 中进行调试。接下来我想在 Windows Server 2008 R2 和 IIS 7.5 上上传网站。我安装了必要的 Windows 托管工具并在 IIS 中创建了 Web 应用程序。问题是,在我尝试打开该页面后,它返回了 404 错误。正如我在任务管理器中看到的,我的应用程序是 运行,但在侦听模式下停止了。

在日志文件中我只看到这些条目:

Hosting environment: Production
Content root path: C:\inetpub\wwwroot\MySite
Now listening on: http://localhost:20706
Application started. Press Ctrl+C to shut down.

IIS 集成似乎有问题。我的 web.config 文件如下所示:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="..\..\approot\MySite\MySite.exe" arguments="" forwardWindowsAuthToken="true" stdoutLogEnabled="true" />
    <httpErrors errorMode="Detailed" />
  </system.webServer>
</configuration>

我尝试了 GitHub 中的一些解决方法,这些方法影响了 Startup.cs 文件的 Configure 方法,但没有成功。

有什么想法吗?

好的,我遇到了多个问题,但我的网站无法运行的两个主要原因是:

  1. 我无法从两个不同的地方启动代码。我本来是把wwwroot的内容放在wwwroot文件夹下的(没那么奇怪),剩下的放到approot里了。现在一切都应该在同一个文件夹中。
  2. 我的发布版本不想工作。我必须使用调试文件夹的内容。不知道为什么。

现在一切正常

仅供参考.. 应用程序文件夹中缺少此 web.config 文件。 该文件应位于:C:\wwwwroot\myapp\

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\XXX.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
    </system.webServer>
  </location>
</configuration>

不要忘记将 XXX.exe 替换为正确的 Web API exe 名称。