0

我正在 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", optional: true, reloadOnChange: true);
                    //.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, 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, levelOverrides: null, isJson: true, fileSizeLimitBytes: 10485760, retainedFileCountLimit: 3)
                    .AddConsole()
                    .AddDebug()
                    //.AddEventLog()
                    .AddEventSourceLogger()
                    /*.AddTraceSource(sourceSwitchName)*/));

有谁知道是什么问题?

谢谢!

4

1 回答 1

0

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

于 2020-09-29T07:56:28.820 回答