Asp.net-core – IIS fails to run ASP.NET Core site – HTTP Error 502.5

asp.net-coreasp.net-core-mvc

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?

Best Answer

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.

Related Topic