已部署 IIS ASP.NET 5 BETA 8 站点到 IIS 出现 HTTP 错误 500.19 - 内部服务器错误

IIS Deployed ASP.NET 5 BETA 8 site to IIS gives HTTP Error 500.19 - Internal Server Error

我创建了一个新的 ASP.NET5 Beta 8 Web 应用程序。

我将其发布到我的本地文件系统并将这些文件复制到我的服务器,该服务器是 Windows Server 2012 R2

在服务器上的 IIS 8.5 中,我创建了一个使用应用程序池的应用程序,该应用程序池使用 Process Model -> Identity as LocalSystem。

然后我将路径指向复制的已发布应用程序的 wwwroot 子文件夹

我的web.config

<configuration>
  <system.webServer>
    <handlers>
      <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
  </system.webServer>
</configuration>

运行直接在服务器上URL或者在IIS中点击浏览

http://localhost/WebApplication1

我收到以下错误

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

我使用的是 Visual Studio 2015 ASP.NET 5 Beta8 Web 应用程序模板中的默认 web.config,所以我只能认为它可能是 .net 版本。

我使用 MSDN method 确定安装了哪个版本的 .NET 4,它对应于 .NET Framework 4.5.1

在我的 project.json 我有

  "frameworks": {
      "dnx451": { }
  },

我发布的时候编译成Win CLR

当我转到部署目录中的 approot 文件夹时,我可以 运行 web.cmd Web 服务器,然后通过创建的端口访问我的网站。

http://localhost:5000/

并且此网站正常运行。

如果我查看我的 IIS 服务器角色安装的组件

ASP.NET 4.5 已安装。

应用程序池正确。

ASP.NET 4 个网站 运行 在 IIS 中正确使用相同的应用程序池

我的问题 1. 为什么IIS 说web.config 无效? 2. 如何在 IIS 中将 ASP.NET 5 Beta 8 站点设置为 运行?

HttpPlatformHandler 是先决条件,因此您需要安装它,

https://azure.microsoft.com/en-us/blog/announcing-the-release-of-the-httpplatformhandler-module-for-iis-8/

[更新:对于 RC2 及更高版本,需要一个新模块而不是 HttpPlatformHandler,https://github.com/aspnet/Announcements/issues/164]

ASP.NET 5 Beta 8 的托管模型已更改,现在依赖于 IIS HttpPlatformHandler.

您会注意到 wwwroot 文件夹中的 web.config 或者您的应用程序包含对它的引用。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
    </handlers>
    <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
  </system.webServer>

上面的%DNX_PATH%翻译成“..\approot\web.cmd”

ASP.NET BETA 8 release notes

Hosting ASP.NET 5 applications in IIS will now be achieved using the IIS HttpPlatformHandler configured to forward through to the ASP.NET 5 Kestrel server. The HttpPlatformHandler is a native IIS module that needs to be installed by an administrator on the server running IIS (installers: x86, x64). It’s also already included with the beta8 Web tools update for local development on IIS Express. This native IIS module manages the launching of an external application host process (in this case dnx.exe) and the routing of requests from IIS to the hosted process.

您可以使用 Microsoft Web 平台安装程序或单独的 x86/x64 安装程序安装 HttpPlatformHandler,下载链接来自 Microsoft 的 IIS 站点:link.

注意:HttpPlatformHandler 仅支持 IIS 8 +。因此,这意味着对于像 Windows Server 2008 R2 这样带有 IIS 7.5 的旧操作系统,您将无法使用 IIS 来托管 ASP.NET 5 个网站,因为这些版本不支持 HttpPlatformHandler。

我的项目使用:ASP.NET 核心 Web 应用程序 (.NET Framework)
这是因为我计划使用 IIS 和 Windows,所以不需要完全使用 Core

我找到这个 link:Install the .NET Core Windows Server Hosting Bundle
在那里你会发现这个link:.NET Core Windows Server Hosting
上面的第二个 Link 将自动尝试下载并安装“Microsoft .NET Core 1.0.0 Windows 服务器托管”捆绑包。
我喜欢第一个 Link 因为它实际上解释了你为什么需要它。

在我的服务器上安装后,我的网站终于开始运行了!
不再有 HTTP 错误 500.19 :)
我将我的应用程序池保留为 .net 4(我没有 not 将其设置为“No Managed Code") 按照说明去做。我还没有尝试过,但我认为既然我选择使用 .NET Framework,我仍然需要它。

使用 ASP.Net Core 1.0 您必须在 IIS 主机上安装 ASP.NET Core Module。你可以 get it here.