简体   繁体   English

从IIS运行ASP.NET Core 2.0应用的HTTP错误502.5

[英]HTTP Error 502.5 running ASP.NET Core 2.0 app from IIS

I'm getting an HTTP 502.5 error when trying to run my ASP.NET core 2.0 web app from IIS. 尝试从IIS运行ASP.NET Core 2.0 Web应用程序时出现HTTP 502.5错误。

I've installed the .NET Core Windows Server Hosting Bundle and checked all my IIS settings as per this document https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?tabs=aspnetcore2x 我已经安装了.NET Core Windows Server主机捆绑包,并根据本文档https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index检查了所有IIS设置? tabs = aspnetcore2x

The web.config looks like this. 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="dotnet" arguments=".\\OscarWeb.dll" stdoutLogEnabled="true" stdoutLogFile=".\\logs\\stdout" /> </system.webServer> </configuration> 

The Windows event log produces the following errors. Windows事件日志产生以下错误。

在此处输入图片说明

It is IIS v6.2 running on Windows Server 2012 R2. 它是在Windows Server 2012 R2上运行的IIS v6.2。 The web application was built using ASP.NET Core 2.0. 该Web应用程序是使用ASP.NET Core 2.0构建的。

When I run dotnet from the commandline as follows there are no errors: 当我从命令行如下运行dotnet时,没有错误:

dotnet oscarweb.dll dotnet oscarweb.dll

The first thing you have to do in this scenario is to create the logs folder if it is missing and check the stdout logs generated. 在这种情况下,您要做的第一件事是创建缺少的logs文件夹并检查生成的stdout日志。

It can be several different things but from personal experience the most common issue i had was IIS not having enough permissions to run it. 可能有几种不同的情况,但是根据个人经验,我遇到的最常见问题是IIS没有足够的权限来运行它。 In IIS you can configure the Identity used in Advanced Settings. 在IIS中,您可以配置“高级设置”中使用的身份。 If it is using ApplicationPoolIdentity then change it to LocalSystem and see if it works. 如果使用的是ApplicationPoolIdentity,则将其更改为LocalSystem,然后查看其是否有效。 The logs in the stdtout file however will give you the answer. 但是,stdtout文件中的日志将为您提供答案。

The solution to this problem (in my case at least) was to reboot the web server. 解决此问题的方法(至少在我的情况下)是重新启动Web服务器。 After installing the .NET Core Windows Server Hosting Bundle you need to reboot the server for them to be registered correctly. 安装.NET Core Windows Server Hosting Bundle后,您需要重新启动服务器以正确注册它们。

Thanks to Chris Pratt (first comment underneath my question) for suggesting the answer :) 感谢克里斯·普拉特(克里斯·普拉特)(我的问题下方的第一条评论)建议答案:)

Not sure if your webconfig is complete. 不确定您的webconfig是否完整。 I believe aspnetcore tag needs to have the ASPNETCORE_ENVIRONMENT environment variable set as well. 我相信aspnetcore标记也需要设置ASPNETCORE_ENVIRONMENT环境变量。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\OscarWeb.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" >
        <environmentVariables>
            <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="YourRuntimeEnv" />
        </environmentVariables>
    </aspNetCore>
  </system.webServer>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM