Поделиться через


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="https://blogs.msdn.com/myapp/WebResource.axd?d=oTrMXXyr9lkT4MbMovPbCw2&amp;t=632681794331014707" mce_src="https://blogs.msdn.com/myapp/WebResource.axd?d=oTrMXXyr9lkT4MbMovPbCw2&amp;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

  • Anonymous
    April 13, 2006
    The comment has been removed

  • Anonymous
    July 02, 2006
    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...

  • Anonymous
    February 15, 2007
    Ta det inte så hårt, jag vill bara se om vi kan få lite liv i kommentarer och diskussioner så varför

  • Anonymous
    June 04, 2010
    The comment has been removed