Debugging ASP.NET AJAX with Visual Studio 2005 and Vista

When it comes to debug JavaScript lot's of people feel such a pain (or even think it's impossible) the fact is solution exists but is not obvious.

The problem is you can't add breakpoint in your Js code "This is not a valid location for a breakpoint." on VS 2005 unless you move it to an external Js file.

Dan Walhin made a good video tutorial where he shows us every steps needed to debug client side script :

Video : Debugging ASP.net Ajax Application with Visual Studio 2005

Basically, you have to tweak IE to enable client script debugging :
Go to Tools > Internet Options > Advanced and uncheck both "Disable script debugging (Internet Explorer)" and "Disable script debugging (Other)" .

Then in your client code use debug.fail() Microsoft AJAX method to launch debugging, and as you have the message "There is no source code available for the current location", use the Script Explorer window (Debug > Windows > Script Explorer) to get a list of all loaded Js scripts, then you can select one, debug and step-in your client code and also into the AJAX Framework!

But... no way for me to make it work with Visual Studio 2005 on Vista (and file system web app) !

So if you are stuck like me maybe you'll need to do more work :

  1. Install Visual Studio 2005 SP1
  2. Install Visual Studio 2005 SP1 Update for Windows Vista Beta

You also need to start Visual Studio 2005 with admin privilege (right click VS shortcut "Run as administrator").

Chances are now you'll be able to hit F5 and step through your client code in VS (if not go to the link at the end of this post).

Debugging Js code in VS 2005

Later I found a very good article from Mike Volodarsky which describe a lot more on the subject, specially if you are using IIS :

Fix problems with Visual Studio F5 debugging of ASP.NET applications on IIS7 Vista

No Comments