If you've carried out any coding in ASP.NET then you understand how critical debugging is. By default Visual Studio comes with its personal stripped down web service that it runs every single time you debug your application as a way to serve up pages. 90% of the time that little net server just isn't powerful or quick enough to maintain up with an enterprise level application. A lot of organizations will have you map your web site to [Internet Information Services][IIS] that is a suitable internet server that comes with Windows. IIS features a lot a lot more possibilities and is much more robust for application hosting (understandably considering that which is its whole goal) whereas the little web service that starts inside the default configuration of visual studio hardly compares.


The downside of possessing your application run by IIS is that it's not immediately apparent how you can debug the application. Pressing F5 nevertheless tries to launch the dinky internet service that comes with Visual Studio. Lots of people speedily determine that they could attach to the procedure thread began by IIS for the application it's operating. It really is generally named one thing like "w3wp.exe". You do this by going to the "debug" menu in Visual Studio and then choosing "Attach to Process". This brings up a bit window having a list of running processes. Obtaining the IIS method for the application and clicking attach will then start Visual Studio's debugger. You are able to then hit the pages hosted by IIS and hit your breakpoints within your code.

Even though this really is fine and functions, it is a giant discomfort to visit Debug > Attach to Process every single single time you must debug your application. You can generate a macro that would do the work for you personally, but why create a macro when Visual Studio will actually do it for you. Let me show you how to setup your project to work with IIS by default when debugging. You will not ever need to navigate your procedure tree once more.

You'll find two forms of internet projects in .NET, Internet sites and Web Applications. There is considerably debate about which 1 is far better for development, but this post is not about that so I will not get into it right here. Nonetheless, these two project varieties have distinct properties menus and configuring them to use IIS when debugging is slightly different in each and every of them. For simplicity's sake I decided to break it up into two sections, one for net apps, and one for websites. Please see the section that corresponds for your project variety. (If you're making use of ASP.NET MVC then you are utilizing a internet application)

Web sites

If your project is actually a website and not a net app, then listed below are the measures to configure it to use IIS when debugging. This assumes you already have IIS setup and hosting your project.

  1. First open up your project and open the solution explorer.
  2. Right-click on your project node and navigate to "Property Pages".
  3. Navigate to "Start Options" item in the left pane.
  4. In the "Server" section make sure "Use custom server" is checked.
  5. In the "Base URL:" field put in the address you have mapped to your project. (Usually the address you put in your hosts file)
  6. You're basically done, but another option I like to set on this page is "Don't open a page. Wait for request from an external application." I set this because I don't like closing a million browser tabs for every time I debug. I usually just leave my browser open behind visual studio and when I debug I prefer to just switch to the browser and refresh rather than have Visual Studio open a new tab.

Web Applications

If your project is a web application and not a website, then here are the steps to configure it to use IIS when debugging.

  1. First open up your project and open the solution explorer.
  2. Right-click on your project node and navigate to "Properties".
  3. Find the "Web" tab on the left-hand side.
  4. Under the "Servers" section select "Use Local IIS Web Server".
  5. This next step varies by how you have your project set up.
    • If you have your project mapped to IIS already then simply put the local URL in the "Project Url" field.
    • If you have NOT mapped your project to IIS yet then it is usually more convenient to click the "Create Virtual Directory" button and let it do it for you. (If you have not set up IIS on your machine correctly then this will fail) Note: Keep in mind that this is not the same as creating a new website in IIS. It creates a virtual directory under the default website that comes with IIS. This can cause problems if you were bad and you used application relative paths instead of absolute paths as root relative paths refer to the website root, not the virtual directory root. Learn how to make your web project build absolute paths based on an application relative root path using the tilde (~).

You're basically done, but another option I like to set on this page is "Don't open a page. Wait for request from an external application." I set this because I don't like closing a million browser tabs for every time I debug. I usually just leave my browser open behind visual studio and when I debug I prefer to just switch to the browser and refresh rather than have Visual Studio open a new tab.

Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.