.NET Core publish to IIS - HTTP Error 502.3 - Bad Gateway - The specified CGI application detected an error and the server terminated the process

I am trying to publish to .NET the ASP.NET .NET Core website that I upgraded from RC2 to RTM.

As a health check, I was able to publish a template / sample application "ASP.NET Core Web Application (.NET Framework)" from Visual Studio 2015.

But for some reason, when I publish the updated RTM application, I get an error message HTTP 502.3 - Bad Gateway An error was detected in the specified CGI application, and the server terminated the process.

The site is running IIS Express from Visual Studio.

How can I debug this? Does anyone have any ideas?

Error 502.3

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=".\MyApp.exe" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /> </system.webServer> </configuration> 

project.json

 { "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true, "warningsAsErrors": true }, "dependencies": { "Microsoft.AspNetCore.Diagnostics.Elm": "0.1.0", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0", "Microsoft.AspNetCore.Authorization": "1.0.0", "Microsoft.AspNetCore.Diagnostics": "1.0.0", "Microsoft.AspNetCore.Hosting": "1.0.0", "Microsoft.AspNetCore.Hosting.Abstractions": "1.0.0", "Microsoft.AspNetCore.Http.Extensions": "1.0.0", "Microsoft.AspNetCore.Localization": "1.0.0", "Microsoft.AspNetCore.Mvc": "1.0.0", "Microsoft.AspNetCore.Routing": "1.0.0", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", "Microsoft.AspNetCore.Session": "1.0.0", "Microsoft.AspNetCore.StaticFiles": "1.0.0", "Microsoft.Extensions.Caching.SqlServer": "1.0.0", "Microsoft.Extensions.Logging.Console": "1.0.0", "Microsoft.Extensions.Logging.Debug": "1.0.0", "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0", "Microsoft.AspNetCore.Razor.Tools": { "version": "1.0.0-preview2-final", "type": "build" }, "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0", "Microsoft.Extensions.Logging": "1.0.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0" }, "frameworks": { "net461": {} }, "tools": { "BundlerMinifier.Core": "2.0.238", "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" }, "scripts": { "prepublish": [ "bower install", "dotnet bundle" ], "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" }, "publishOptions": { "include": [ "wwwroot", "web.config", "appsettings.json", "**/*.cshtml", "Config/*.json" ] ] } } 
+17
source share
3 answers

How can I debug this? Does anyone have any ideas?

Here are three ideas:

  • Read this and make sure you write everything he says.

  • Run the published .\MyApp.exe from the command line. It works?

    • If so, you know that you have an IIS integration issue.
    • If this is not the case, you know that you have a problem with the application.
  • Change stdoutLogEnabled="false" to true , and then check the logs at stdoutLogFile=".\logs\stdout" . A mistake there may say something.

  • Check the IIS application logs in the event viewer. A mistake there may say something.

Event Log Application Logs

Event Viewer Application Logs

+10
source

If you run the task for a long time, and the web browser does not receive a response in 2 minutes (the default request time), you will receive this error. Because after the timeout, IIS will replace the application to respond to the client with a "Bad Gateway".

Perhaps you need to change the request time in the web.config file.

Set the requestTimeout attribute in the system.webServer / aspNetCore section to specify how long the main ASP.NET module will wait for a response from a process listening on% ASPNETCORE_PORT%.

  • requestTimeout should be specified only for whole minutes, otherwise it defaults to 2 minutes.

Similar:

 <system.webServer> <aspNetCore requestTimeout="00:20:00" ... /> </system.webServer> 
+9
source

The solutions did not help me, but what I did:

Turn on the web developer mode (press F12 in your browser) => application tab => and delete all cookies. Refresh the page and voila: it works. You can also copy your URL and paste it into another browser where you have not run any MVC projects.

My project worked on Internet Explorer and Microsoft Edge without any changes. It is possible that the cause of your mistake.

+2
source

Source: https://habr.com/ru/post/1257411/


All Articles