15 March, 2021
0 Comments
1 category
After updating a .NET Core 2.2 app to NET 5, the following error appeared:
System.InvalidOperationException: ‘Application is running inside IIS process but is not configured to use IIS server.’
To fix this use HotBuilder instead of WebHostBuilder
public class Program
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.UseKestrel(serverOptions => serverOptions.AddServerHeader = false)
.UseIISIntegration()
.UseStartup<Startup>();
});
}
Category: Uncategorized