Blog on software engineering
NET 5 – Fix – System.InvalidOperationException: ‘Application is running inside IIS process but is not configured to use IIS server.’

NET 5 – Fix – System.InvalidOperationException: ‘Application is running inside IIS process but is not configured to use IIS server.’

 

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>();


            });


}

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.