Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish a .Net 5.0 web in IIS from Visual Studio 2019 doesn't start

I am trying to publish a test website in .Net 5.0 on an IIS on Windows 10.

  • I have .Net 5.0 installed
  • I have activated the IIS on Windows
  • I have installed the ASP.NET Core 5.0 Runtime (v5.0.1)
  • I have installed the dotnet-hosting-5.0.1-win
  • I have created the web application in the IIS and assigned it a specific Pool with the .Net CLR version "No code managed" and "Integrated". I have assigned the port 8090.

From Visual Studio when Publish I selected:

  • File System
  • Configuration: Release
  • Target Framework: 5.0
  • Deployment Mode: Self-Contained
  • Target Runtime: win-x86 (with win-x64 it doesn't work either)

My Windows version is 1909 (OS compilation 18363.1256)

If I navigate to the path http://localhost:8090/ I get this error "HTTP Error 500.32 - Failed to load .NET Core host.

I have reset the IIS, I have deleted and recreated the application, I have restarted Windows, but it still does not start the test web.

The Windows event viewer showed me these errors:

  • Unable to load 'C:\inetpub\wwwroot\TestNetCore.\hostfxr.dll'. This might be caused by a bitness mismatch between IIS application pool and published application.
  • Could not find 'aspnetcorev2_inprocess.dll'. Exception message:
  • Failed to start application '/LM/W3SVC/2/ROOT', ErrorCode '0x800700c1'.

I don't know what else to look at. Any ideas or suggestions?

enter image description here

enter image description here

like image 425
Dalamar Avatar asked Jan 24 '23 13:01

Dalamar


1 Answers

Your errors are in ASP.NET Core, For these errors, you can try the following solutions:

  • Have you install asp.net core module? if not, please install it: ASP.NET Core Module
  • Open IIS manager > Application Pool > Select App pool > Advanced Settings, update "Enable 32 bits applications" from false to true > Click OK.

enter image description here

  • Try to delete the applicationhost.config (in .vs\config\applicationHost.config) and rebuild app.
like image 139
samwu Avatar answered Apr 27 '23 17:04

samwu