[英]“HTTP Error 500.30 - ASP.NET Core app failed to start” with IIS
I deployed a API .NET Core 5 service with the Publish feature.我部署了一个具有发布功能的 API .NET Core 5 服务。 When I start the service with cmd with command
dotnet <service-name>.dll
, it runs but I cannot make API request.当我使用 cmd 和命令
dotnet <service-name>.dll
启动服务时,它运行但我无法发出 API 请求。 When I start it with IIS, it shows me the following error当我用 IIS 启动它时,它显示了以下错误
HTTP Error 500.30 - ASP.NET Core app failed to start
Common solutions to this issue:
- The app failed to start
- The app started but then stopped
- The app started but threw an exception during startup
Troubleshooting steps:
- Check the system event log for error messages
- Enable logging the application process' stdout messages
- Attach a debugger to the application process and inspect
I searched around the internet this error, but I didn't find a solution for my problem.我在互联网上搜索了这个错误,但没有找到解决我的问题的方法。 This is my
program.cs
这是我的
program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.UseNLog()
//.UseContentRoot(Directory.GetCurrentDirectory())
.UseKestrel()
.UseIISIntegration()
.UseStartup<Startup>();
//.Build();
});
Errors from EventViewer来自事件查看器的错误
.NET Runtime .NET 运行时
Application: w3wp.exe
CoreCLR Version: 5.0.721.25508
.NET Version: 5.0.7
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException: Application is running inside IIS process but is not configured to use IIS server.
at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at LogService.Program.Main(String[] args) in C:\DEV\LogService\LogService.API\Program.cs:line 19
IIS AspNetCode Module V2 IIS AspNetCode 模块 V2
Application '/LM/W3SVC/2/ROOT' with physical root 'C:\LogService\' hit unexpected managed exception, exception code = '0xe0434352'. First 30KB characters of captured stdout and stderr logs:
crit: Microsoft.AspNetCore.Hosting.Diagnostics[6]
Application startup exception
System.InvalidOperationException: Application is running inside IIS process but is not configured to use IIS server.
at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
Unhandled exception. System.InvalidOperationException: Application is running inside IIS process but is not configured to use IIS server.
at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at LogService.Program.Main(String[] args) in C:\DEV\LogService\LogService.API\Program.cs:line 19
Application '/LM/W3SVC/2/ROOT' with physical root 'C:\LogService\' failed to load coreclr. Exception message:
CLR worker thread exited prematurely
It works with current configuration它适用于当前配置
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.UseNLog()
//.UseContentRoot(Directory.GetCurrentDirectory())
//.UseKestrel()
.UseIISIntegration()
.UseIIS()
.UseStartup<Startup>();
//.Build();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.