Debug javascript generated by webresource.axd

Ran across this the other day and thought someone else may find it useful.  Javascript for the ASP.Net 2.0 controls is typically generated by a request to webresource.axd.  For example when you add a menu control, you see the following in the page:

<script src=";t=632681794331014707" mce_src=";t=632681794331014707" type="text/javascript"></script>

If you browse the above URL, you get a .js file as output.  If you wanted to debug this script (or other .js files) at runtime, you can use the Script Explorer included with Visual Studio 2005. 

  1. Ensure IE is setup for debugging (Internet Options | Advanced tab).  After you enable debugging in IE, you must restart the browser.
  2. Attach the debugger to the browser.  You can do this by pressing F5 in Visual Studio 2005 or by using Attach to Process on the Debug menu.
  3. From the Debug menu, select Windows, then Script Explorer (keyboard shortcut Ctrl+Alt+N).  The page and script files open in the browser are displayed.
  4. Double-click the page to open the HTML output of the page
  5. Double-click the script file
  6. Set breakpoints and perform an action to trigger the script

To debug inline script, you can either move the script to a .js file, use stop commands, or set a function breakpoint.

If Script Explorer is missing for you, you can use the keyboard shortcut (Ctrl+Alt+N), or add it to the IDE.  Here's how to add in the Script Explorer to a toolbar or menu:

  1. Tools menu, select Customize
  2. Command Tab
  3. Select Debug on the left, find Script Explorer on the right 
  4. Drag Script Explorer to a toolbar or menu

Comments (4)
  1. psiegers2006 says:

    Hi Jerry, if I click the axd file in Script Explorer it doesn’t appear. Why is that?

  2. simone_b says:

    For me either psiegers2006. Try double-clicking another document in the ScriptExplorer window and then again on the axd file, it should do  the trick. Looks like another bug in VS… and they want to release orcas…

  3. Ta det inte så hårt, jag vill bara se om vi kan få lite liv i kommentarer och diskussioner så varför

  4. Walter says:

    Another way (assuming script debugging is allowed in IE) is to intentionally put a javascript line in the place you want to debug that has a syntax error.  The code will break there in debugging mode.  You can then step over the syntax error line, the step into things and use the immediate window, etc.

Comments are closed.

Skip to main content