Brent
Brent

Reputation: 195

Hosting .NET 5 ASP.NET app on Window 10 Pro IIS

I have a simple, functional .NET 5.0 console app that I'm trying to host (for testing) on my local Windows 10 Pro development machine.

I have the Application Pool setup as "No Managed Code" and "Integrated". I have a website created that points to the folder that I've published my app to.

My app uses NLog and when I hit the app's URL, I do see that NLog is logging things correctly.

Yet my app isn't functioning and when I check the Windows Application Event Log I see:

Source: IIS AspNetCore Module V2
Event ID: 1007
Message: Application '/LM/W3SVC/5/ROOT' with physical root 'C:\Cabinet\Learning\EssApiGateway\Mobile.ApiGatewayPublished\' failed to load coreclr. Exception message:
Managed server didn't initialize after 120000 ms.
File Version: 15.0.21076.5. Description: IIS ASP.NET Core Module V2 Request Handler. 

I have installed the .NET Core Hosting Bundle from here and restarted IIS: https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-aspnetcore-5.0.5-windows-hosting-bundle-installer

Can I not host a .NET 5 ASP.NET console app on Windows 10 Pro IIS?

Thanks, Brent

Upvotes: 1

Views: 3197

Answers (1)

Brent
Brent

Reputation: 195

I've solved this, sort of.

In Program.cs, I am creating a new WebHostBuilder() and I was calling .UseKestrel(). When I changed that to UseIIS(), my gateway project runs and functions correctly when hosted by IIS.

But then when I run my project in VS.NET by using the project's launch profile (how I typically run these type of projects), it fails with this error:

'No service for type 'Microsoft.AspNetCore.Hosting.Server.IServer' has been registered.'

But then if I run my project in VS.NET with the IIS Express launch profile, it again runs and functions fine.

So I need to educate myself about the components involved so I better understand...

Upvotes: 2

Related Questions