61
votes

We have a Windows 2012 R2 machine. I had an existing ASP.NET Core site on it that had a working published ASP.NET Core site running.

However when I published to the site again today a month later after I made changes, I can't access the site anymore and get the following error in my browser

HTTP Error 502.5 - Process Failure

For more information visit: http://go.microsoft.com/fwlink/?LinkID=808681

If I log onto the server and click on the exe in my deployed directory it opens a command prompt and shows my site on port 5000. If I access the site on http://localhost:5000 it works perfectly so the problem is to do with IIS and not the site itself.

If I log onto the server I can see the following in Windows EventViewer

enter image description here

Application 'MACHINE/WEBROOT/APPHOST/DEFAULT WEB SITE/MySite' with physical root 'D:\Sites\MySite\' failed to start process with commandline '"%LAUNCHER_PATH%" %LAUNCHER_ARGS%', ErrorCode = '0x80070002 : 0.

When I visit the link in the browser error message it mentioned reinstalling the .net Core Hosting bundle which I did. However the error message in the browser is the same.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore requestTimeout="02:00:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
  </system.webServer>
</configuration>

When I look at my app log folder a stdout file does get created for every time it tries to access this site but each time it is of size 0KB and empty contents.

Why does IIS refuse to work suddenly where it worked previous but the app works if I access the compiled exe directly?

19
That web.config change doesn't work. The one posted in the answer does.dev2go
BELIEVE IT OR NOT: IN MY CASE, IT HAPPEND BECAUSED I'VE CREATED THE PROJECT WITH SPACES ON NAMEMarco Alves
My 502.5 was from a NullReferenceException in Program.cs -- I found the line by starting the application from the command line -> docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/…IEnjoyEatingVegetables
Change <AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName> to AspNetCoreModuleV2 then it will read processPath="%LAUNCHER_PATH%"Pierre

19 Answers

57
votes

Your problem is a bad web.config file:

<aspNetCore requestTimeout="02:00:00" 
     processPath="%LAUNCHER_PATH%" 
     arguments="%LAUNCHER_ARGS%" 
     stdoutLogEnabled="true" 
     stdoutLogFile=".\logs\stdout" 
     forwardWindowsAuthToken="false" />

The path %LAUNCHER_PATH% does not exist on your system, it is not even valid. It should be something like:

<aspNetCore requestTimeout="02:00:00" 
     processPath=".\yourAppName.exe" 
     arguments="somePossibleArgument" 
     stdoutLogEnabled="true" 
     stdoutLogFile=".\logs\stdout" 
     forwardWindowsAuthToken="false" />

Notice that the web.config file is completely ignored if the app is launched from the command line, that's why you do not receive the error.

47
votes

I had this same problem, My issue were IIS was not able get the path to dotnet. I was able to fix it by specifying the path to the dotnet.exe

<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="C:\Program Files\dotnet\dotnet.exe" arguments=".\your-project.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"/>
  </system.webServer>
</configuration>
11
votes

My problem was that the process wouldn't start due to an invalid escape sequence in my appsettings.json file.

I'm using dotnet to run the published ASPNET Core 2 web api dll. The problem was revealed by opening a command prompt and navigating to the directory where the site files are located. Once there, I ran the command:

dotnet mySite.dll

(change mySite.dll to the main dll of your app. Also, make sure the correct version of the .NET Core Windows Server Hosting bundle is already installed).

Pressing enter, it immediately crashed giving the exact feedback in the console window of what was wrong. That's a great way to help determine your startup error(s) if you are having similar troubles.

7
votes

Problem: When I deploy asp net core web API, the processPath is set to dotnet. The app does not launch and the event viewer shows the above error.

Solution:

The application pool identity should be setup to load profile.

Navigate to: Application Pool -> NetCore (your pool) -> Advanced Settings -> Load User Profile ----> Set this to true

I verified turning to false recreates the error and setting back to true solved it.

4
votes

I had a similar issue. I just followed the Troubleshooting steps: Check the system event log for error messages and found the following from the Event Viewer, Application 'MACHINE/WEBROOT/APPHOST/[MyFolder]' with physical root 'C:\inetpub\wwwroot\[MyFolder]\' failed to start process with commandline 'dotnet .\MyApp.dll', ErrorCode = '0x80004005 : 80008083.

I then re-ran dotnet .\MyApp.dll from a terminal and got the answer:

It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '2.1.1' was not found.
  - Check application dependencies and target a framework version installed at:
      \
  - Alternatively, install the framework version '2.1.1'.

So the reason is the same as answered by jv_, you just don't have a compatible framework version installed. I ended up using "Self-Contained" Deployment Mode and it worked.

3
votes

This completely drove me mad given I've tried all possible fixes found online but nothing worked for me. Until I found out the issue was that I had a space in my project name: App WebAPI.dll. So when "dotnet .\App WebAPI.dll" tries to execute it fails because it's really trying to execute "dotnet .\App" and forgetting the second part after the space. Renaming my solution and project names to remove spaces (AppWebAPI) fixed my issue. I hope this fix saves people time trying to figure out the issue.

2
votes

I ran into this same problem when I deployed my application. There were several problems on my end :)

I went through this page very carefully: ASP.NET Core: Publishing to IIS

First, I didn't have all parts of the .NET Core Windows Server Hosting bundle installed. I ended up doing a fremework-dependent deployment instead of a self-contained deployment. We have a lot of apps and don't want/need each on their own versions of .net core. There would be way too many versions of .net on the box.

Also, note that if your admins performed any updates/upgrades to the server, they could have jacked up your ASP.NET Core installation (see ASP.NET Core: Publishing to IIS troubleshooting section)

Then, I had to fix my web.config... here is my working published web.config: I didn't publish as an *.exe, I did *.dll (notice my arguments value). Also, my processPath is set to "dotnet".

<?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=".\DT.Web.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
  </system.webServer>
</configuration>

Also, ensure that your project.json options are all set compatible with your server environment (see ASP.NET Core: Publishing to IIS troubleshooting section)

Here is a copy of the of my project.json if it can be of any help:

{
  "version": "2.0.1.0",

  "dependencies": {
    "DT.Common": "2.*",
    "DT.Configuration": "2.*",
    "DT.Services": "2.*",
    "DT.Web.ViewModels": "2.*",
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
    "Microsoft.AspNetCore.Authentication": "1.1.0",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
    "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0",
    "Microsoft.AspNetCore.Session": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.Extensions.Caching.SqlServer": "1.0.0",
    "Microsoft.Extensions.Configuration.Abstractions": "1.1.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.Graph": "1.1.1",
    "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.13.6"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": "portable-net45+win8+dotnet5.6"
    },
    "Microsoft.Extensions.Caching.SqlConfig.Tools": "1.1.0-preview4-final"
  },

  "frameworks": {
    "netcoreapp1.1": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ],
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.1.0",
          "type": "platform"
        }
      }
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "views/**/*.cshtml",
      "appsettings.json",
      "appsettings.*.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "bower install", "gulp buildprod" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}
2
votes

I had the same problem with Visual Studio transforming the web.config file and changing the processPath and arguments. As outlined on the Microsoft site you can add the exclusion in the project.csproj file:

<PropertyGroup>
  <IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>

This has taken care of my problem with it changing the path value on publish, I am still having issue however with Visual Studio changing it on its own when debugging.

1
votes

My project was working fine in development but after web deploy/publish to production it was throwing 502.5 Process Failure.

The reason turned out to be that i had updated from using Microsoft.AspNetCore.All 2.0.5 to 2.0.6. Worked fine after reverting the version back.

1
votes

For me the solution was just to install .Net Core 2.2 SDK and it worked.

1
votes

In my case this HTTP Error 502.5 happened when I cloned some pretty old git repos which contained web projects targeting .NET Core 1.1... sometime ago I uninstalled .NET Core 1.1 runtime from my windows machine.

So I went and downloaded the runtime and installed it again. Got the latest one from this page which is 1.1.13:

https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-1.1.13-windows-x64-installer

All good now. Back to work. :-)

0
votes

I had same issue except for me I had updated my Visual Studio on my dev environment and the server needed .NetCore run-time updated. Once I updated the run-time on the server I was good to go again.

I guess my inexperience with VS 2017 updating was my issue ;-)

0
votes

For me, after a while, I understood the problem is related to one of property in

appsettings.json

file.
I have a property that name is Version. The format is like this :

"Version": "1.0.6",

On the server our support team did not consider this format and it was like this :

"Version": 1.0.6,

and IIS faced 502.5 error.
I could see Application Event Log and it helped me.

0
votes

When the team I worked on had this issue, someone just build the project with visual studio and zipped up the bin folder.

You need to run the dotnet publish command so that the msbuild tasks will build your web.config file correctly. It should replace the %LAUNCHER_PATH%" and "%LAUNCHER_ARGS% variables.

0
votes

I faced the same issue and nothing from this thread worked out for me. So I looked into Windows Event Viewer and found that the user didn't have sufficient permissions to create/modify database as I was using EF core DB migrations. Fixing the authorization solved this issue.

Therefore, I would suggest reviewing your application events and hopefully you will get the root cause of your error there.

0
votes

It is sometimes due to the Space in Assembly name or Namespace name.

Try to Avoid Space.

Goto Project>>[Project] Properties>> {Application Tab} Change Assembly Name and Default Namespace Name, Remove Spaces!

0
votes

I wanted to be able to run my .Net Core based API from IIS from my development directory without fighting with the web.config file. Visual Studio is controlling the web.config based on the project profile settings. You just need to add an IIS profile to your debug start so that VS knows what to do with your web.config. Instructions are here.

Now I can just code a bit, compile and refresh my browser without waiting for a browser launch, and without losing my query string each time. Clicking Debug automatically attaches VS to IIS for debugging, which means no more manually attaching the debugger to w3wp, which is something that has annoyed me for ages. Perfect!

For reference, VS is changing my web.config dynamically to this:

<aspNetCore processPath="bin\IISSupport\VSIISExeLauncher.exe" arguments="-argFile IISExeLauncherArgs.txt" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
  <environmentVariables />

But, I would not hard code this into the web.config, just let VS manage it. :)

0
votes

Responding to some of the users who mentioned problems with the application name or path:

I ran into this problem with the "WebApp-OpenIDConnect-DotNet" sample project (https://github.com/AzureADQuickStarts/WebApp-OpenIdConnect-DotNet) which ran fine for me in IIS Express, but not IIS.

As it turns out, from diving into the .NET source code at https://github.com/dotnet/aspnetcore/blob/master/src/Servers/IIS/AspNetCoreModuleV2/CommonLib/HostFxrResolver.cpp, because the assembly name ended with "-DotNet.exe" (or maybe just DotNet.exe), it was going down the path of assuming it was supposed to run as a stand-alone app. Hence the complaint about missing arguments. I tore my hair out over this for a good long time before a search for the error string from the Windows Event Log took me to the source file.

Changing the assembly name so it didn't end with "-DotNet.exe" solved the problem for me.

I should add that I was actually getting a 500.30 error rather than 500.5. But this thread brought me the closest to solving the problem so I'm posting my solution here.

Hope that helps someone.

0
votes

Oh guys, My site was also working fine and all of sudden it started to show this error. My site was hosted under go daddy. Their technical team was also helpless to figure out the exact issue. I tried all the comments above none of them were working fine. So after spending a lot of time what resolved is,

I kept processPath as it is like processPath="dotnet" in my web.config, Just before showing this error i did some changes to my appsettings.json file to update my connection string. I edited it using filezilla (using view/edit option) in my local machine. So it might got corrupted i guess, which also caused this issue.

So what i did is, i published my project locally once again and i did my connection string updates locally in my appsettings.json and deployed this latest changes to godaddy. After this deployment my site started to show up again.