27 September 2015

Debugging Web Applications hosted in IIS using Visual Studio

In the past 1 month, I have explained 3 people on how to debug web applications (ASP.NET, ASP.NET MVC) and Web services (ASMX, WCF services) hosted in IIS using Visual Studio IDE. So thought it would be beneficial for the developers who are beginners in .NET Web Application development.

Steps to debug Web Apps running in IIS using VS IDE

(Assuming you have already hosted your web application in IIS)
  1. Open the web application solution in Visual studio as an Admin and build it. Ensure the web site browse-able by using URL hosted in IIS.
  2. Now in the DEBUG menu in the toolbar click on the "Attach to Process" menu item (alternatively you can also use shortcut key Ctrl+Alt+P combination) to open the "Attach to Process" window.
  3. Ensure you check the check-boxes "Show Process from All users" and "Show process in all sessions" in the "Attach to Process" window. This will ensure you will start seeing the W3WP.EXE process in the list.
  4. Now find the W3WP.EXE process with the Application pool same as your Web Application is using.

    The Username column indicate the application pool for which the W3WP.EXE corresponds to.

    In this case the Application pool is "ASP.NET v4.0".

  5. Select the right W3WP.EXE process and click on "Attach" button. In the "Attach Security Warning" click Attach.
  6. Then add a break point to the line of code you wish to debug and browse the URL which hit that line of code.

    Before the line code is going to get executed, your break point will be hit and you will able to debug your application.

No comments:

Post a Comment