.NET Core 3.1 OutOfProcess和AspNetCoreModule:应用程序在加载时挂起

问题描述

我正在Visual Studio 2019上开发.NET Core 3.1 + Angular Web应用程序。 我已经从包含的VS模板创建了该项目,到目前为止一切正常。 当我尝试在Plesk上发布Web应用程序时,遇到了已知的错误

HTTP错误500.0-ANCM进程内处理程序加载失败

我已经解决了在 .csproj 文件中设置以下内容错误

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

不幸的是,在进行了这些更改之后,当我尝试在Debug中运行该应用程序时,它会无限挂起并加载,没有任何错误

这是我的 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",reloadOnChange: true);
                    //.AddJsonFile($"appsettings.{env.EnvironmentName}.json",reloadOnChange: true);
#endif

                    config.AddEnvironmentvariables();

                    if (args != null)
                    {
                        config.AddCommandLine(args);
                    }
                })
                // https://docs.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,retainedFileCountLimit: 3)
                    .AddConsole()
                    .AddDebug()
                    //.AddEventLog()
                    .AddEventSourceLogger()
                    /*.AddTraceSource(sourceSwitchName)*/));

有人知道是什么问题吗?

谢谢!

解决方法

Plesk不正式支持.net核心。因此,您需要登录到服务器并创建新的应用程序池并将其设置为“无托管代码”,您可以参考这篇文章https://windowswebhostingreview.com/simple-step-to-fix-http-error-500-30-ancm-in-process-start-failure/

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...