Why do I get this error when running my ASP.NET Core MVC project with IIS Express?

254 views Asked by At

I started to install .NET 8 and create a new ASP.NET Core MVC web app project, and realized that IIS Express is needed to run the project.

So after installing it, I activated it through turn window feature on or off and also repaired the Hosting Bundle. But when I see the applicationhost.config file in config/templates path, the following lines:

<add name="AspNetCoreModule"...
<add name="AspNetCoreModuleV2"...

do not exist in the file, While I read somewhere, apparently they should be added after repair. now in rider IDE by pressing the run button, I get this error:

Process finished with exit code -1,073,741,502

and my project does not run.

2

There are 2 answers

0
Lex Li On

"While I read somewhere, apparently they should be added after repair" is wrong. ASP.NET Core module for IIS Express isn't installed from the standard Hosting Bundle like you assumed but as part of VS installation. So your steps to install IIS and Hosting Bundle have no impact on IIS Express and that's expected.

To test .NET 8 with your ASP.NET Core project at this very moment, make sure you choose IIS in VS, not IIS Express.

You can switch back to IIS Express once your VS2022 is updated after .NET 8 is officially released by Microsoft.

0
YurongDai On

In order to host ASP.NET Core applications, IIS Express relies on the ASP.NET Core module. When you check if the module is present in the IIS Express configuration file %\PROGRAMFILES(x86)%\IIS Express\config\templates\PersonalWebServer\applicationhost.config. You have installed the module if at least one of the following lines is present:

<add name="AspNetCoreModule"...
<add name="AspNetCoreModuleV2"...

However, according to your description, these lines do not exist in the configuration file.

In case IIS Express does not start or returns an empty error, there is a chance the .NET Core Hosting Bundle did not install correctly. Please refer to this article (under Fixing the applicationhost.config template) may help troubleshoot and fix the default IIS Express configuration template on your machine.

Related reference documents:

Run and debug ASP.NET Core apps in IIS Express

ASP.NET Core on IIS Express - Empty error starting application

Running and debugging ASP.NET Core apps in IIS Express with Rider