.NET Core 3.1 OutOfProcess and AspNetCoreModule: app hangs on loading

349 views Asked by At

I'm developing a .NET Core 3.1 + Angular web application on Visual Studio 2019. I've created the project from the included VS template and till now all works fine. When I've tried to publish the web application on Plesk I've encountered the known error:

HTTP Error 500.0 - ANCM In-Process Handler Load Failure

I've solved that error setting the following in .csproj file:

<AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>

Unfortunately, after those changes, when I try to run the app in Debug it hangs and load infinitely, without any error.

This is the host builder configuration in my Program.cs:

public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder => webBuilder
                .UseUrls("http://localhost:5000", "http://*:80")
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .ConfigureAppConfiguration((hostingContext, config) =>
                {
                    // delete all default configuration providers
                    config.Sources.Clear();

                    var env = hostingContext.HostingEnvironment;
#if DEBUG
                    config.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
#else
                    config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
                    //.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
#endif

                    config.AddEnvironmentVariables();

                    if (args != null)
                    {
                        config.AddCommandLine(args);
                    }
                })
                // https://learn.microsoft.com/it-it/aspnet/core/fundamentals/logging/?view=aspnetcore-3.1
                .ConfigureLogging(logging => logging
                    // clear default logging providers
                    .ClearProviders()

                    // add built-in providers manually, as needed
                    // Serilog https://github.com/serilog/serilog-extensions-logging-file 
                    .AddFile("Logs/Errors/{Date}.txt", Microsoft.Extensions.Logging.LogLevel.Error, levelOverrides: null, isJson: true, fileSizeLimitBytes: 10485760, retainedFileCountLimit: 3)
                    .AddFile("Logs/Warnings/{Date}.txt", Microsoft.Extensions.Logging.LogLevel.Warning, levelOverrides: null, isJson: true, fileSizeLimitBytes: 10485760, retainedFileCountLimit: 3)
                    .AddConsole()
                    .AddDebug()
                    //.AddEventLog()
                    .AddEventSourceLogger()
                    /*.AddTraceSource(sourceSwitchName)*/));

Does anyone know what is the problem?

Thank you!

1

There are 1 answers

0
TheGunners On

Plesk doesn't officially support for .net core. So you need to login to server and create new application pool and setup it to No Managed Code, you can refer to this post https://windowswebhostingreview.com/simple-step-to-fix-http-error-500-30-ancm-in-process-start-failure/