Reputation: 2990
I have a rather simple .NET WebApi application which I'm trying to host inside IIS. Followed all of the instructions from MS site about this. here is the startup method for it.
public static void Main(string[] args)
{
var host = WebHost.CreateDefaultBuilder(args)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
I configured the Application pool to not use any managed code but I'm getting still this error in logs
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.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
I'm out of any ideas what can be wrong. Any suggestions?
Using .NET Core 2.2
Upvotes: 3
Views: 5760
Reputation: 366
I want to use UseKestrel()
.
When I create .net core 2.0 or 2.1 project. I can use UseKestrel()
But If I create .net core 2.2 project I couldn't use UseKestrel()
I solved this problem like that
But it is not effective solution.
Upvotes: 0
Reputation: 29976
For InProcess
, it uses IISHttpServer
.
For your code, you are configuring UseKestrel()
which uses out-of-process
.
For solution, remove the .UseKestrel()
line.
public static void Main(string[] args)
{
var host = WebHost.CreateDefaultBuilder(args)
//.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
For more details, refer ASP.NET Core Module.
Upvotes: 9