Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application is running inside IIS process but is not configured to use IIS server .NET Core 3.0

I have migrated our application from .NET Core 2.2 to version 3.0. Actually I created the new application in 3.0 from scratch and then copied source code files. Everything looks great but when I try to run the application within Visual Studio 2019 I get the exception:

Application is running inside IIS process but is not configured to use IIS server

Here is my Program.cs

public static class Program {     public static void Main(string[] args)     {         CreateHostBuilder(args).Build().Run();     }      public static IHostBuilder CreateHostBuilder(string[] args) =>         Host.CreateDefaultBuilder(args)             .ConfigureWebHostDefaults(webBuilder =>             {                 webBuilder.UseContentRoot(Directory.GetCurrentDirectory());                 webBuilder.UseKestrel();                 webBuilder.UseIISIntegration();                 webBuilder.UseStartup<Startup>();             }); } 

The error occurs at the line: CreateHostBuilder(args).Build().Run(); It worked fine in .NET Core 2.2 but it doesn't want to run as 3.0. I cannot find anything else that should be done. Something new in the Startup.cs? I don't know.

like image 284
Ondrej Vencovsky Avatar asked Sep 24 '19 12:09

Ondrej Vencovsky


People also ask

Can IIS store .NET Core process directly without dotnet process?

With ASP.NET Core 2.2 there's now an In Process hosting model on IIS which hosts ASP.NET Core directly inside of an IIS Application pool without proxying to an external dotnet.exe instance running the . NET Core native Kestrel Web Server.

Does .NET Core require IIS?

The most important thing to understand about hosting ASP.NET Core is that it runs as a standalone, out of process Console application. It's not hosted inside of IIS and it doesn't need IIS to run.


1 Answers

I also came across this issue while following the documentation https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio

For your case I have checked and the code below will work, with the call to webBuilder.UseKestrel() removed.

public static IHostBuilder CreateHostBuilder(string[] args) =>        Host.CreateDefaultBuilder(args)            .ConfigureWebHostDefaults(webBuilder =>            {                webBuilder.UseContentRoot(Directory.GetCurrentDirectory());                webBuilder.UseIISIntegration();                webBuilder.UseStartup<Startup>();            }); 
like image 141
Satyajit Avatar answered Sep 21 '22 08:09

Satyajit