Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS...

15
Debug the ASP.NET Web Application which is hosted on "Remote IIS Server" Introduction: Suppose we are developing a web application on our local system which is hosted on remote IIS o or web server and now we need to debug it. How will we do that? This is one of the most challenging tasks in ASP.NET. Debugging Features for ASP.NET available in Visual Studio Microsoft has provided following three ways to debug the web application from Visual Studio: 1. Visual Studio Internal Debugger 2. Local IIS Debugging 3. Remote IIS Debugging Visual Studio Internal Debugger: Microsoft has provided its own internal ASP.NET debug engine which is used to debug the ASP.NET web application while we are developing it. WebDev.WebServer.Exe process is used to debug the application within visual and ASP.NET Engine uses WebDev.WebServer.exe to debug the application

Transcript of Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS...

Page 1: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

Debug the ASP.NET Web Application which is hosted on "Remote IIS Server"

Introduction:  Suppose we are developing a web application on our local system which is hosted on remote IIS o or web server and now we need to debug it. How will we do that? This is one of the most challenging tasks in ASP.NET.

Debugging Features for ASP.NET available in Visual Studio

Microsoft has provided following three ways to debug the web application from Visual Studio:

1. Visual Studio Internal Debugger2. Local IIS Debugging 3. Remote IIS Debugging

Visual Studio Internal Debugger:  Microsoft has provided its own internal ASP.NET debug engine which is used to debug the ASP.NET web application while we are developing it. WebDev.WebServer.Exe process is used to debug the application within visual and ASP.NET Engine uses WebDev.WebServer.exe to debug the application

Fig: Visual Studio Internal Debugger

Page 2: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

Local IIS Debugging:

In local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging the application hosted on IIS from visual studio, we need to attach the worker process (w3wp.exe) with in visual studio. After that we will able to start the debugging of the web application

Fig:  Debugging ASP.NET site from Local IIS Server 

Remote IIS Debugging:Remote IIS Debussing is very helpful when we do not have an IIS Server installed on our local system. It means that if out application code is running on our local system but the Website is deployed on different IIS server. Microsoft has provided "msvsmon.exe" to setup and configure the Remote debugging process with Visual Studio.

Page 3: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

Fig:  Remote debugging of ASP.NET Application

Debugging with msvsmon.exe

Fig:  Remote debugging of ASP.NET Application with msvsmon

Page 4: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

First of all we have to start the msvsmon.exe on to the remote server, and our development system is the debugger host where we will debug our code.Msvsmon.exe is installed to the following paths:Install path\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x86 

First of all we need to Run the Application from the location and we will get following screen,

 Fig: Initial startup of msvsmon.exe

At the time of starting of application the window will show the status message "Msvsmon started a new server named '<ServerName>'. Waiting for new connection". Which means Debugging monitor tool is ready to connect with some remote server. Now I can connect with this remote server and get the list of all process that is running on the server.

Configure Authentication Mode Configuration of msvsmon tool is very easy. The main configuration is involves with the authentication mode. Msvsmon support two types of authentication

Windows Authentication  No-Authentication 

 Windows Authentication 

Msvsmon provide highlevel security with the windows authentication mode. The user who want to debug the application remotely he should be authenticated, means he should have sufficient permission to access the debugging facility from the remote system. For Setup the Windows authentication mode, We have go "Tool" > "Options" . Following window will appear,

Page 5: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

Fig: Setup and configure security settings

Now we have a permission button along with the windows authentication radio button. Using that, we can give permission to any user who belongs to that windows group. If we click on the Permission button, following screen will appear

Page 6: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

 

  Fig: Add user for windows authentication

By default, Administrator should have the permission for remote debugging, we can use add button to add new user and can give the Debug access or Deny the Debug persmission to any user. For example, I have added myself by just clicking on Add button and take the access control.

Page 7: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

  Fig: Add user for windows authentication 

 

Now, I have give me the permission for debugging from remotely (from Debugger Host).

  Fig: Debug permission for selected user 

Similiarly we can select any user from Active Directory and can deny the request for remote debugging though the user is Windows authenticated user.

I have discussed about how to debug remotely with windows authentication mode in the process attache section.

No-Authentication 

There is no security involved with this authentication mode. Any one can debug remotely, if the authentication mode is set to "No-Authentication". As this debugging mode is not at all secure, so it should be used only on secure network.

 

   Fig: No-Authentication Mode Configuration

No Authentication mode only supports native debugging. You can also guess the behaviour from the warning message. We have a "Allow any User to Debug" check box. If we checked that one, any user can able to debug.

Page 8: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

In the next section I have described, how to attach the process for remote debugging for both Windows and No Authentication Mode.

Attach Process from Remote SystemNow, Remote Debugger is ready to accept a new connection to start remote debugging. And we have already gone through how to configure the msvsmon for both windows and No-Authentication mode. Now we will check how to connect with them and start debugging,

Before what we need to do, we have created a Web application and hosted it IIS where msvsmon is running, We need to connect it from our local system where we are having our code. Now lets have a look in the case of  windows authentication mode

 Process Attach - Windows Authentication Mode   

First of all we need to open the application from visual studio in our development system. Now we need to attach the process from remote server.  Goto Tool > Attach Process 

  Fig: Attach Process From Visual Studio

When we will click on the "Attach to Process" we will get the following screen .

Page 9: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

  Fig: Default Process List

Right now it is showing all the process that are currently running on the system. Now we need to connect it the remote system. Now I have already started a msvsmon with name "abhijit.jana" and it is waiting for a new connection.

  Fig: msvsmon is running on remote host

Page 10: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

Now, I am going to connect with the remote system from my local visual studio IDE. So, what we need to do. We have to give the remote server name to the Qualifier section in attach process window.

  Fig: Connect with Remote host and get the list of process

 Now, in the process list all the process are listed from remote server along with Worker Process ((w3wp.exe). Now this is the exact worker process which we need to attach with our code. One more thing, when we are getting the list of process from it means remote server is connected. Now if we check the msvsmon window, it will show another message that user is connected. Have a look into the screenshot

Page 11: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

   Fig: Debug monitor showing message of connection

Now, our application is ready to debug. just set a break point in your code and enjoy the debugging.  Here is our web site [ Hosted on Remote IIS Server ] and which having a server side button, and I want to debug the application on the click of button.

  Fig: Access site from Host URL

Now process is attached in our visual studio and I have set the breakpoint on the button click method. Here is outcome.

  Fig: Debugger at breakpoint

So, let enjoy the debugging from remote server . Now lets have a look how will we remote debug in No-Authentication mode.

Process Attach - No Authentication Mode

This is quite similar to windows authentication process attach. I have already discussed that, how to configure the No-Authentication mode in remote debugger. We have to attach the process similar way that I have discussed. There are some few changes. Transport mode should be selected to -Remote (Native only with no authentication) [ Check the Screen shots] .And we need to provide the qualifier "abhijit.jana: 4015". Have a look into screen shots,

Page 12: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

  Fig: Process Attach for No-Authentication Mode

So, now we need to attach the worker process and need to start debugging, on which I have already discussed. There is slight change in connect while remote debugging going on with No-Authentication mode. Debugging monitor will display a message on the window that debugging is running on no authentication mode.

   Fig: Status message for No-Authentication Mode

So, this is all about how to debug you application from remote IIS server in both windows and No-Authentication mode.

Debugging For Multiple User This is one of the most fantastic features of Msvsmon tool. Msvsmon debugging monitor tool allow multiple user to debug simultaneously. . Each instance of the remote debugger has a unique server name. As I have already shown that Server names are configurable, so we  can give an instance of the remote debugger any server name. Now multiple user can able to access the same

Page 13: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

  Fig: General block diagram from Multiple Debugger instance

 

Some Important Tips while remote debugging Visual Studio 2005 remote debugging components must be installed on the remote computer we must reference the remote computer by using a computer name instead of an IP address. The Web.config file for the ASP.NET application must not contain any errors, and the compilation

element must have the debug attribute set to True. Make sure that a firewall is not blocking remote debugging.  The security setting for the site must allow Integrated Windows authentication. Make sure that the Remote Debugging Monitor is running on the remote server. If Msvsmon.exe is not

running, you receive the following error message.

Summary : Now to finalize the things, just take a quick summary. msvsmon is an utility which provides the facility to debug the application which is hosted on remote IIS server. It provides two kind of authentication mode, Windows and No-Authentication Mode. In Case of windows authentication mode the user should need the permission to access the instance of remote debugger but on the other hand No-Authentication does not required and security permission.

Page 14: Introduction: - vijaypratapblog.files.wordpress.com … · Web viewIn local IIS debugging, IIS should be installed in the local system where we have visual studio installed. For debugging

  Fig: Overall Summary

Hope this article will help you to learn about remote debugging. Please Don't forget give your suggestion and Feedback for imporvement.