More JavaScript debugging goodness (with ASP.NET)

So in my haste to share this little gem here I forgot to mention some of the quirks that aren’t obvious when you try to do this with JavaScript in an .aspx file.  I am a big fan of not explaining something someone else has already explained.  You can learn more about the quirks in the “Internet Explorer Known Debugging Issues and Workarounds” section here

My preferred approach to get JavaScript debugging working with .aspx files is to create a corresponding .js file for every .aspx file in my project and put my JavaScript “code beside” my .aspx page. For example, if I have a file called default.aspx the IDE generates a default.aspx.cs “code behind/beside” file for me.  This is where I put my server side ASP.NET code.  I will then create a default.aspx.js file for my client side “code beside” JavaScript.  I then reference default.asp.js in my in the default.aspx markup a script tag.

This gives me the same clean separation between markup and code that I have server side.  JavaScript breakpoints work as expected with this approach.  Set a breakpoint, and click the “start debugging” button on the toolbar or hit F5.  Hope this helps.


Comments (2)

  1. Sean Gahan says:


    I am still using VS 2003 and the way that I debug JavaScript is by setting the break points in the script and then attach the debugger to aspnet_wp and iexplore.  Will this method work in VS 2005 as well?

    Best regards,

    Sean Gahan

  2. FederalDev says:


    This method will still work, but the gotchas are still there.  However, VS2005 no longer requires IIS to build and debug ASP.NET applications.