How to host website on IIS

In this tutorial let us go through steps of hosting asp.net website on IIS(Internet Information Services). In this tutorial I am hosting mvc website on IIS which is installed on local machine.

Steps to Host .net Website on IIS (Internet Information Services)

Step 1: To open IIS in command prompt type “inetmgr” as shown in below screenshot:

Inetmgr option to open IIS

Step 2: In IIS right click on Sites option and then select Add Website as shown below:

Add Website option in IIS

Step 3: In Add Website Dialog window enter name for new website, In Physical path browse for the location of website on computer which you want to host. In Port number specify port on which site to be hosted, default port number is 80.

Physical path of website on IIS hosting

Step 4: After doing setting as mentioned in step 3 click on Ok button:

Port number for website in IIS

Step 5: Now site is added into IIS, to run site on browser right click on website and then select Manage Website->Browse as shown below:

how to open website in browser from IIS

If everything is configured correctly, then site will be hosted on IIS. Now you will be able to run asp.net website from IIS.

 

Debug Site Hosted on IIS using Visual Studio

This tutorial guides through the steps required to debug an asp.net website which is hosted locally on IIS. By following steps mentioned here a user can debug any asp.net site using Visual Studio IDE.

Note: Important point to keep in mind is that visual studio should run as an administrator. To run VS as an administrator right click on it and then select the option Run as administrator as shown below:

How to run Visual Studio as an Administratro

Step 1: Make sure the site is running through IIS locally, to run site select the option browse as shown in screenshot below:

Run or browse site from IIS

Step 2: In visual studio apply the breakpoint where you want to start the debugging. In this tutorial I am running default MVC application and applied breakpoint on Index action of Home Controller.

Select menu Debug and then click on option Attach to process or use keyboard shortcut Ctrl+Alt+P as shown below:

Attach to process for debugging site using IIS

Step 3: In Attach to Process window all the process running on your system would be shown. Make sure to select the check box show processes from all users. Then look for w3wp.exe process as shown in below screenshot. Each website hosted on IIS run under w3wp.exe process:

w3wp.exe for IIS debugging

Step 4: Click on Attach button. Now your asp.net website is ready for debugging , just open the website in browser and try to hit the page where breakpoint is applied. As you open the page where breakpoint is applied debugging will get started as shown below:

Debugging asp.net from IIS locally windows 10

Using above steps .net website can be debugged locally which is hosted on IIS. Let me know in comment section if you face any challenge with above steps.