DomBurf
DomBurf

Reputation: 2522

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.

I've installed the .NET Core Windows Server Hosting Bundle and checked all my IIS settings as per this document https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?tabs=aspnetcore2x

The web.config looks like this.

<?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.

enter image description here

It is IIS v6.2 running on Windows Server 2012 R2. The web application was built using ASP.NET Core 2.0.

When I run dotnet from the commandline as follows there are no errors:

dotnet oscarweb.dll

Upvotes: 0

Views: 3148

Answers (3)

DomBurf
DomBurf

Reputation: 2522

The solution to this problem (in my case at least) was to reboot the web server. After installing the .NET Core Windows Server Hosting Bundle you need to reboot the server for them to be registered correctly.

Thanks to Chris Pratt (first comment underneath my question) for suggesting the answer :)

Upvotes: 1

Milan Vidakovic
Milan Vidakovic

Reputation: 466

Not sure if your webconfig is complete. I believe aspnetcore tag needs to have the ASPNETCORE_ENVIRONMENT environment variable set as well.

<?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>

Upvotes: 0

Nick Chapsas
Nick Chapsas

Reputation: 7200

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.

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. In IIS you can configure the Identity used in Advanced Settings. If it is using ApplicationPoolIdentity then change it to LocalSystem and see if it works. The logs in the stdtout file however will give you the answer.

Upvotes: 2

Related Questions