HTTP Error 500.30 ASP.NET Core app failed to start

By FoxLearn 11/14/2024 4:12:15 AM   116
The "HTTP Error 500.30 - ASP.NET Core app failed to start" error typically indicates that there is an issue with your ASP.NET Core application that prevents it from starting up properly.

You deployed an ASP.NET Core, but when you try to access the site, you encounter the error "HTTP Error 500.30 - ASP.NET Core app failed to start."

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
For more information visit: https://go.microsoft.com/fwlink/?LinkID=2028265

You can check stdout log file, this Error appears

at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(ExceptionDispatchInfo info)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load()
   at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at ArtanNet.Program.Main(String[] args) in C:\Users\Administrator\Desktop\FoxLearn\ASPNETDemo\Program.cs:line 16

Program.cs file like this:

public class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
            });
}

First, check which version of ASP.NET Core you are using in your application. This can be found in your project’s .csproj file, then verify the hosting model in use, which can be either In-Process or Out-of-Process.

If you are using In-Process hosting (which runs the app inside the IIS worker process), try changing it to Out-of-Process (where IIS acts as a reverse proxy to the Kestrel server) to see if it resolves the issue.

How to Change the Hosting Model?

Open your .csproj file and check for the following setting

<PropertyGroup>
  <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>

If it's set to InProcess, try changing it to OutOfProcess:

<PropertyGroup>
  <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>

This change can help resolve certain issues related to hosting, especially if there are compatibility problems with the IIS worker process.

You can also fix this issue by changing the Program.cs file, such as add webbuilder.useiis() in creatHostBuilder

public class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
                webBuilder.UseIis();
            });
}

The issue of timeouts during migration from .NET Core 2.0 to .NET 6 was resolved by changing `.UseIISIntegration()` to `.UseIIS()` in the `Program.cs` file.

By following these steps, you should be able to identify and resolve the root cause of the 500.30 error after publishing your app to IIS.