1

Usually, when developing ASP.NET, I host the root of the project in IIS. This helps me to just build and directly access the web application in the browser without launch it in visual studio debug mode.

Here is how I set up IIS in ASP.NET MVC :

I can open the site in browser simply just typing localhost/site-name with the above setting. But this method seems doesn't work in ASP.NET Core MVC.

I have set the application pool to no managed code as it is required for .net core.

But the browser just display the directory

So far, i have to do either below process in order to view the site in browser properly :

  • Launch it in Visual Studio debugging mode (url : localhost:[port]), or
  • Publish it using visual studio publisher (Go to menu Build > Publish), and host it an IIS Application with above setting. (url: localhost/site-name)

But it kindly slows down the development process in my opinion.

3
  • Does this answer your question? How to host my ASP.NET core site on IIS (in development environment, without deploy / publish) Commented May 11, 2020 at 6:46
  • Hi LexLi thank you, the link you provide is close to my question and answer's refference in that link is the same with @seangwright here. I mark seangwright 's answer as the right one since he provide the better explanation on how it works in .NET Core Development process :) Commented May 14, 2020 at 10:25
  • I don't think the link I provided gives the same information and Visual Studio development-time IIS support is completely a different thing. Commented Jul 26, 2023 at 14:53

1 Answer 1

1

Missing module

Checkout the docs for hosting ASP.NET Core in IIS

There is a reference to the ASP.NET Core Module for IIS which is described as:

The ASP.NET Core Module is a native IIS module that plugs into the IIS pipeline to either:

  • Host an ASP.NET Core app inside of the IIS worker process (w3wp.exe), called the in-process hosting model.
  • Forward web requests to a backend ASP.NET Core app running the Kestrel server, called the out-of-process hosting model.

So you will need to have this module installed in IIS for your setup to work correctly.

A better alternative

That said, there is an easy way to run ASP.NET (Full Framework or Core) applications in Visual Studio without having to debug to run the app.

Instead of clicking the green "Play" button every time you want to run the site, go to the "Debug" menu at the top of the window and select "Start Without Debugging".

The application will start and launch. Then when you make changes you only have to rebuild the project. The next time you make a request to the application in the browser the app will serve results using the latest changes.

You don't need to re-run the application every time you make changes - it's always running!

If you want to Debug after having started the application using "Start Without Debugging", you can "Attach" to the IIS Express process and start debugging.

Open the "Debug" menu, select "Attach to Process", filter the list for "iisexpress", and select that process.

Visual Studio will load debug symbols and allow you to hit breakpoints.

Then when you want to stop debugging, hit the red "Stop" button. You will detach from the process, but the application will continue to run.

You can attach and detach as many times as you want. Just make sure that after you make changes to your code you re-build the project before attaching to make sure the correct debug symbols are loaded.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.