0
votes

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://docs.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

3
Did you restart the machine after installing the hosting bundle?Chris Pratt
I'll give that a try. We have users on the server using other app so will need to reboot when everyone has gone home.DomBurf
Well, if you can't/don't want to do a full reboot, you must at least stop the IIS service completely (iisreset is not enough). Don't remember the command off the top of my head, but should be easy enough to find. One or the other must happen, though, before IIS can actually use the modules the hosting package installs.Chris Pratt
This github issue says that 0x80070002 error means "file not found" (the "file" may be missed or IIS doesn't have right). Also, check this issue on github > the sites were in a non-standard location and IIS did not have read rights to that folder. Changing the application pool to run as Administrator helps.Set
@ChrisPratt After a reboot over the weekend your suggestion has worked. The ASP.NET Core 2.0 app now works perfectly. Thanks for the advice.DomBurf

3 Answers

2
votes

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.

1
votes

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 :)

0
votes

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>