Visual Studio 2010 script debugger doesn't work for me

后端 未结 8 502
礼貌的吻别
礼貌的吻别 2020-12-14 06:23

I just installed VS 2010 Beta 2 and wanted to play with an ASP.NET MVC 2 project. I simply added some script (alert(\'hello\');) into the Home controller\'s in

相关标签:
8条回答
  • 2020-12-14 06:39

    When debugging on IE, VS seems to add a folder called 'Script Documents' to the Solution Explorer. Inside this folder there is another folder called 'Windows Internet Explorer', and inside of it I see all the loaded js scripts and the (compiled) HTML file currently being displayed on IE. Setting breakpoints on the script tags in this HTML file does work for me.

    0 讨论(0)
  • 2020-12-14 06:41

    I have found that the Google Chrome devloper tool shows the JavaScript perfectly. In my case, I'm normally loading the script with jQuery's getScript function and execution of the code is typically by way of a jQuery callback upon loading a page or handling an event. With Visual Studio 2010, I frequently encountered the "No source" bug. Sad I need Chrome to debug JavaScript that is part of my Visual Studio project.

    0 讨论(0)
  • 2020-12-14 06:41

    Using a separate js file has its drawbacks. For instance, you can't use MVC helpers. Microsoft really needs to figure this one out.

    Intellisense also does not work properly in script blocks on a view, even if you include the reference comments like this:

    /// <reference path="/Scripts/jquery-1.6-vsdoc.js" />
    /// <reference path="/Scripts/jquery-1.6.js" />
    

    Intellisense works fine in the js file with this approach though.

    0 讨论(0)
  • 2020-12-14 06:43

    The debugger cannot debug both Silverlight code and Script code at the same time, if the Silverlight debugger is selected JavaScript debugging is switched off.

    1. Go to the Project's Properties (Alt+Enter).
    2. For a Web Site Project: Select "Start Options". Or for a Web Appliction: Go to the Web tab and at the bottom you will see the Debuggers option.
    3. Check that the Silverlight checkbox is NOT ticked if you want to be able to debug JavaScript. (It is unfortunate that the UI here is not clear about this side effect.)
    0 讨论(0)
  • 2020-12-14 06:46

    As Ryan noted above, I moved my script to a seperate file under the Scripts folder. I also added debug into the name of the script so it became MyTestScript.debug.js. I included the script via a script tag and could set break points in the script file which the debugger hit.

    0 讨论(0)
  • 2020-12-14 06:47

    I was having the same issues. I was not able to get the IDE to even break at a breakpoint set inside a script tag. However when I added "debugger;" as the first line in the script tag was able to get the IDE to respond but then only to say that the disassebly was not availble.

    However, I was able to click on the debug tools like "step into" and "step over". When I did this the IDE did progress into some of the external scripts that I am using (JQuery and Google Maps). So I took the JavaScript code block out of the view and put it into a separate .js file in the "Content" folder. Then I added a script tag to reference this new .js file (url = "/Content/Test.js").

    It worked... a little bothersome that you have to go through this effort but maybe there is something to be said for JavaScript not being included directly in a view. I hope this is a bug they intend to fix.

    0 讨论(0)
提交回复
热议问题