Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

How to: Enable Client-Side Script Debugging

The Visual Studio debugger provides you with a comprehensive debugging environment for testing and correcting errors in your Web document scripts. You can use the Visual Studio debugger to test scripts written in Microsoft Visual Basic Scripting Edition (VBScript) and Microsoft JScript.

You can use the Visual Studio debugger to debug client-side scripts in an ASP.NET page. Client-side scripts consist of statements that appear on the HTML page. Microsoft Internet Explorer executes the script when the document is loaded, or in response to an event such as a button click.

Setting a Breakpoint in Client-Side Script

If you want to set a breakpoint in client-side script, you cannot just set the breakpoint in the project's .aspx file. The .aspx file is a server-side document, and breakpoints set there are not translated to the client-side document. Instead, you can set a client-side breakpoint using either of the following methods.

To set a breakpoint in client-side script

Enabling Script Debugging

Script debugging is disabled in Internet Explorer by default. To debug a client-side script application, you must first enable script debugging in Internet Explorer.


The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To enable script debugging in Internet Explorer 5.5 or later

  1. On the Tools menu, click Internet Options.

  2. In the Internet Options dialog box, click the Advanced tab.

  3. In the Browsing category, clear the Disable script debugging check box.

  4. Click OK.

  5. Close Internet Explorer, to make this option take effect.

In addition, to hit breakpoints in client-side script, a cookie called ASPCLIENTDEBUG cookie must be set. If this cookie is not set automatically, you can set it manually using the following procedure.

To manually set ASPCLIENTDEBUG cookie

  1. Create an HTML text file that contains the following code:

    <script language="JavaScript">
    function set ()
     var expdate = new Date(); 
     alert("setting cookie \""+form1.txtName.value+"\" to \""+form1.txtValue.value+"\"");
     setCookie(form1.txtName.value, form1.txtValue.value, expdate); 
    function get ()
     alert("getting cookie \""+form1.txtName.value+"\"");
     var c = getCookie(form1.txtName.value);
     alert( "cookie = "+c );
     form1.txtValue.value = c;
    function getCookie (sCookieName)
     var sName=sCookieName+"=", ichSt, ichEnd;
     var sCookie=document.cookie;
     if ( sCookie.length && ( -1 != (ichSt = sCookie.indexOf(sName)) ) )
        if (-1 == ( ichEnd = sCookie.indexOf(";",ichSt+sName.length) ) )
        ichEnd = sCookie.length;
        return unescape(sCookie.substring(ichSt+sName.length,ichEnd));
     return null;
    function setCookie (sName, vValue)
     var argv = setCookie.arguments, argc = setCookie.arguments.length;
     var sExpDate = (argc > 2) ? "; expires="+argv[2].toGMTString() : "";
     var sPath = (argc > 3) ? "; path="+argv[3] : "";
     var sDomain = (argc > 4) ? "; domain="+argv[4] : "";
     var sSecure = (argc > 5) && argv[5] ? "; secure" : "";
     document.cookie = sName + "=" + escape(vValue,0) + sExpDate + sPath + sDomain + sSecure + ";";
    function deleteCookie (sName)
     document.cookie = sName + "=" + getCookie(sName) + "; expires=" + (new Date()).toGMTString() + ";";
    <form name=form1>
       cookie name:<input type="text" name="txtName" value="ASPCLIENTDEBUG"><p>
       cookie value:<input type="text" name="txtValue" value="doesn't matter"><p>
       <input type="button" value="Set Cookie" onClick="set()">
       <input type="button" value="Get Cookie" onClick="get()">
  2. Save the file as cookie.html.

  3. Copy the file to

  4. In the Internet Explorer Address box, type:

  5. In the http://localhost/cookie.html window, click the Set Cookie button.

Better Error Messages for Script Debugging

Visual Studio provides enhanced error messages for common script debugging problems. You will normally not see these messages unless you attach to Internet Explorer manually instead of having the debugger launch Internet Explorer automatically. If you encounter a problem, use the following procedure to manually attach and get more information.

To manually attach

  1. On the Debug menu, click Windows, and then click Processes.

    The Processes dialog box appears.

  2. If you have already started debugging, select the process you are debugging, and click Detach.

  3. Click OK to close the Processes window.

  4. Right-click the Processes window, and on the shortcut menu, click Attach to Process.

  5. In the Attach to Process dialog box, find Internet Explorer, iexplore.exe, and select it.

  6. Click Select to select the code type to debug.

  7. In the Select Code Type dialog box, under Debug these code types, select Script.

  8. Click OK to dismiss the Select Code Type dialog box.

  9. Click OK to dismiss the Attach to Process dialog box.

  10. At this point, an error message box may appear. If it does, click the Help button to get more information.

See Also

Community Additions

© 2015 Microsoft