Click here to Skip to main content
15,883,883 members
Articles / Programming Languages / C#
Tip/Trick

Remote Debugging on IIS

Rate me:
Please Sign up or sign in to vote.
4.67/5 (2 votes)
25 Mar 2011CPOL4 min read 32.7K   12   2

Introduction


This article helps you to learn how to debug the website deployed on IIS on remote machine using visual studio

Background


There are some situations,when there is a need for finding the cause of any error occuring due to some environmental factors like OS settings,directory settings, Web Server settings etc. in a site deployed on IIS on remote machine.

Steps Involved


Settings to be Done on Remote Machine



  1. Allowing IIS process to be accessed from remote machine
  2. Go to Start'Control Panel'Windows Firewall (path may vary according to OS).


    1. Click on Exceptions, under Exceptions click "Add Port Tab".

    2. Under "AddPort" Tab, provide a friendly Name, Port of IIS (i.e 80 default)and select TCP.
    3. Under "AddPort Tab", Click on Change Scope Tab, select My Network (subnet only),then click OK twice.


    Firewall settings are done.


    • Setting to be done on IIS

    Go to IIS:

    • Right Click particular WebSite (e.g SampleHostApplication),Click "properties".

    Check all check boxes. As shown in Fig below:



    • Then click "Directory security" and then click "Edit" Tab. Make sure "Anonymous Authentication" and "Integrated Windows Authentication" checkbox is checked.

    Click on OK twice.


    As shown in Fig below.





IS settings are done.


  • Setting Remote Debugger Monitor


  1. Go to path "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86" or
    "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86 ", depending on the installation.
  2. Double Click "msvsmon.exe", below is the similar display.

  3. Click on "Tools"'"Permissions", then click "Add" Tab

  4. Enter name of the user who wants to debug the IIS. Click OK twice .Check name,user should be on the same subnet.
  5. Remote Debugger Settings are done.


  6. Website Settings
  7. Go to web.config file of the site and add the compilation Tag mentioned below.

     <system.web;>
          <compilation debug="true" />
    </system.web >


NOTE:


As we want to debug the application on IIS we have to enable it for debugging.


Some more settings are required to be done on Remote machine, but we will discuss them in conjunction with settings to be done on developer machine.


We are done with the settings on the remote machine. Now any website running under IIS on Remote machine can be debugged by the user who is given the permissions.


Setting to be Done on Development Machine


In development environment, we will debug website using Visual Studio. We must have the same codebase for the website as deployed on IIS.

Some Key Points



  1. The version of Remote Debug monitor on remote machine should be compatible with the IDE you are using to debug the application.
  2. Timestamps of ".dll" files should be same as the ".dll" files in the websites running under IIS on tremote machine.

To make sure this we should perform following steps:

  1. "Rebuild" the entire site in visual studio in "debug" mode.
  2. Copy all ".dll" and ".pdb" files from bin folder of the website and paste them in bin folder of the website on IIS on remote machine.

WHY PDB files?


PDB stands for (program debug database),it contains the symbols for the managed code. These symbols allow developer to debug the code using "breakpoints" in visual studio.
It is necessary to place ".pdb" files in bin directory of IIS in order to debug the code running under IIS.

Configuring Visual Studio for Remote Debugging


Open website in visual studio, then perform following steps:

  1. Click on "Tools"'"Attach to process " as shown below:

  2. In "Attach to process",enter the "domain name","username" and "machine name" of the user of that remote machine in the format shown below in the Qualifier name


Make sure that:



  1. In Transport "Default " is selected.
  2. In Attach to: "Automatic:Managed Code" is selected.
  3. Show process from all users is checked.

Now,select IIS process as shown above(aspnet_wp.exe),the process name may vary according to your IIS version .

Note:


If it does not appears in the list of processes remote machine ,type the url of the website in your browser e.g "http://machine name:port/website name/page.aspx" and press enter.IIS process will be launched on remote machine. Click on refresh button shown above you can see the process in the list.


Select the process and Click "Attach".


Now, Visual Studio will initiate the debugger , place breakpoint in your project, wherever you want to debug the code. If the control goes through that particular flow, your debugger will stop on that statement. As shown below:



Now,you can easily debug any website running on IIS on the remote location through your own development enviroment.

Points of Interest


It was required for me to debug the code running on QA machine since same codebase was running fine on my machine,also we dont have IDE there on QA machine.Finally while debugging i found some directory was "read only" on QA machine.Due to which some code was not able to create file to that particular directory.


License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
This member doesn't quite have enough reputation to be able to display their biography and homepage.

Comments and Discussions

 
GeneralReason for my vote of 5 Nice one!! Very useful; thanks a lo... Pin
jawed.ace29-Jun-11 19:50
jawed.ace29-Jun-11 19:50 
GeneralBroken Pin
Indivara23-Mar-11 20:40
professionalIndivara23-Mar-11 20:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.