How to – Debug ASP.NET Applications Hosted on IIS

You have a website deployed on a remote server (VPN or dedicated server, not shared hosting). Your code works fine on your development machine, when you debug there is nothing wrong, and everything is working just fine.

But when you deploy it there are some errors and something is just not right. So you want to debug it on the server. Is it possible? Yes it is! And here is how:

1- Open web.config on the remote host and set debug=”true” in “<compilation>” under <system.web>
2- Find the worker process working for your website

You can do this either using the “Task Manager” or “Command Prompt”.

In the Task Manager you will see a process with name w3wp.exe (Name can change, this is for IIS 7, 7.5. I don't know about the others);

In the command prompt;
-Navigate to Windows/System32/inetsrv
-Type “appcmd list wp”

This will give you a list of worker processes along with their processIDs and application pool names. This way you will know which process to attach if you have multiple web sites hosted on the IIS. (Check out the application pool name!)

3- Attach this process in Visual Studio. Click “Debug” -> “Attach to Process”

4- Put a break point in your page_load.

That's pretty much it. Now browse to your website from another machine and see how you hit the break point in the Visual Studio on your remote machine.

Hope this helps someone.
Good luck,
Serdar

Leave a Reply

Your email address will not be published. Required fields are marked *