ASP.NET Core - HTTP Error 502.5 - Process Failure

Wednesday, September 5, 2018 || 55 || 0 || 5 min(s) read time

Http error 502.5 sounds like the frequency of a radio station here in the heart of Lagos but they can be so painful to comprehend why a code that works on my machine spuriously started showing me this unimaginable error code.

I have been getting this request from some developers on how to host their ASP.NET Core web applications on Plesk Hosting Server. I mean we usually host our websites and web application on Plesk servers we already have provisioned or we have our favourite hosting company already and it is becoming a difficulty for us to deploy our web application on their server.

And I for one as a developer receives this error a lot of time even on Azure. I mean Microsoft Azure! But hey, its not Microsoft’s fault that my code refuses to work because of a change in environment.

I will like to keep this really short as my goal is for you to find a fix and not to bore you with some gory details.

Usually this can happen due to some issues. It could be because U are missing a Library, an SSL/TLS certificate error or that the server doesn’t simply have the right library or the correct version of the framework and hosting dependencies to run your application.

I mean often a lot of times we use the latest libraries from Nuget when developing even those in pre-release mode. And it’s a bit difficult for the server guys to keep.

On some occassions, when you try to deploy an ASP.NET Core website to your server, you can see the following error message:
 

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
To resolve this issue, you need to publish the website/project as a Self-Contained Application. It is safe to tell you that when you are publishing your application on your developer machine, you are mostly doing it as Framework-Dependent Application

 In order to publish it as a self-contained application, please add this to the csproj folder.

<PropertyGroup>

<OutputType>Exe</OutputType>

<TargetFramework>netcoreapp1.1</TargetFramework>

<PreserveCompilationContext>true</PreserveCompilationContext>

<RuntimeIdentifiers>win7-x64;win7-x86;ubuntu.16.04-x64;</RuntimeIdentifiers>

<SuppressDockerTargets>True</SuppressDockerTargets>

</PropertyGroup>


The above is usually necessary if you will be publishing from the command-prompt or PowerShell as this article does. The above is not needed if you will be publishing from the Visual Studio environment itself because it is taken care of for you.

 

The details of the steps are as followed:

Step 1: Download VS 2017 from Microsoft website if you don’t already have this

Step 2: Open solution within vs 2017, you will be told once this happens, you can no longer open the project within vs 2015, that is of course if you are using Visual Studio 2015, however they do backup automatically a version at 2015

Step 3: The xproj file at the heart of the application is transformed into a csproj file. This filetype is *now* editable by right clicking on the Main project heart within the directory, and selecting edit {!ProjectName}.csproj, it should open an XML file format.

step 4. Add these lines to the project. (Please note, the project may contain some of these lines already). Some has to add the runtimeidentifiers and supperdocker targets to a property group that already existed.

step 5. Open the project within the command prompt in the usual method (where you right click the project name, open file explorer at the project location and then crtl+shift clicking within the file explorer and selecting the open with command prompt option.

Step 6. Run: dotnet publish -c Release -r win7-x64 within the command prompt

NOTE: Please run the following command: npm install -g bower - within the nugget package manager console, this is meant to install bower globally or something along those lines. This process will publish a self-contained application of your project within the root directory>Bin>Release>Win64>publish

The command prompt should inform you of the location. That is how the latest and most prevalent 502.5 error that occurs with the 2015 --> 2017 upgrade or missing latest .NET Core or ASP.NET version is rectified.