问题描述
我正在Visual Studio 2019上开发.NET Core 3.1 + Angular Web应用程序。 我已经从包含的VS模板创建了该项目,到目前为止一切正常。 当我尝试在Plesk上发布Web应用程序时,遇到了已知的错误:
HTTP错误500.0-ANCM进程内处理程序加载失败
<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/