HTTP Error 502.5 in .NET core 2.1.3 on window serv

2019-02-27 05:49发布

问题:

I Install .NET core version 2.1.3 for my new computer run window server 2016 OS. I hosted in IIS 10. But it have Error 502

HTTP Error 502.5 - Process Failure

Common causes of this issue:
The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port

This is my snippet for 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=".\WebApplication1.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

回答1:

Ensure the following:

  1. .NET Core Hosting Bundle installed on the hosting server - download from here
  2. Application Pool .NET CLR version set to "No Managed Code"
  3. Ensure that the Application Pool Identity user has read permissions on the published folder. For details check: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.0


回答2:

The is a situation that if you use:

Env: Windows Server OS, .NET Core Hosting Bundle(including runtime), IIS, Asp.Net.Core

You could add a element as follows into {YourProject}.csproj file:

<PropertyGroup>
  <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>

Ref: https://github.com/dotnet/coreclr/issues/13542



回答3:

Alternatively, For anyone who still struggling with .net core on IIS while running nuget package Microsoft.Aspnetcore.all 2.1.3, i will recommend to update the version to 'Latest Stable 2.1.301' as Microsoft has released the fix

Other version with IIS issue is Microsoft.Aspnetcore.all 2.0.8 either upgrade to 'Latest Stable 2.1.301' or downgrade to 2.0.7.

No code or .csproj needed for changing needed.