Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

500.19 error or 502.5 error when hosting asp.net core 2 application inside IIS

While deploying asp.net Core 2 to IIS, you may get one of these errors  or both 

500.19 Internal Server error

The first of the issue is 500.19 error when trying to host an asp.net core 2.0 application inside IIS7. What you get might be  something like below

This one was quite simple,turned out to be ANCM (ASP.NET CORE MODULE) module and related configuration was not correctly recognized by IIS. This can be fixed by installing the .NET Core Windows Server Hosting bundle  .

By installing the .NET CORE Server Hosting bundle ,it added the ANCM module correctly to IIS .When you install the ANCM module,,it will copy dlls and schema files to as follows

C:WindowsSystem32inetsrvaspnetcore.dll

C:WindowsSystem32inetsrvconfigschemaaspnetcore_schema.xml

If you are running IIS application pool on 32 bit ,you should also see it under

C:WindowsSysWOW64inetsrvaspnetcore.dll.

It will also add the required configuration changes to ApplicationHost.Config(C:WindowsSystem32inetsrvconfig) file.You should see AspNetCoreModule in the globalModules section.

 

HTTP Error 502.5 - Process Failure

This error will be like this

If the ASP.NET Core Module fails to start, a 502.5 Process Failure status code page appears. This can be caused by multiple reasons

  • ASP.NET Core Module fails to launch the backend process - This could be because an exception occured in your asp.net core startup.cs 
  • The backend .NET Core process starts but fails to listen on the configured port - You can refer my other blog entry for a similar issue

You web.config will be

 
  1. stdoutLogEnabled should be enabled and look for a log files in the stdoutLogFile location you specified in your web.config file. If this folder is not there,do create the folder and reproduce the issue .
  2. Please note that if you have disableStartUpErrorPage  setting enabled, you will just get regular 502 error page of IIS and not this specific page 
  3. If you don't see anything in the log file,you can add ASPNETCORE_ENVIRONMENT environment variable and also enable developer exception page in your startup.cs 
aspNetCore processPath="dotnet" arguments=".MyApp.dll" stdoutLogEnabled="false" stdoutLogFile="\?%home%LogFilesstdout"> 
environmentVariables>
 environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> 
environmentVariables> 
aspNetCore>

and the startup.cs Configure method should have

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
 {
if (env.IsDevelopment())
 {
 app.UseDeveloperExceptionPage();
 }

After this,you should see the developer exception page in your application which should tell you what is the error your application is running into.

Hope it helps!

Share the post

500.19 error or 502.5 error when hosting asp.net core 2 application inside IIS

×

Subscribe to Msdn Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The Msdn Blogs.

Get updates delivered right to your inbox!

Thank you for your subscription

×