views:

1271

answers:

5

I can't seem to get Javascript debugging working for my ASP.NET MVC application even though I can for a traditional ASP.NET WebForm app.

I have followed the steps for unchecking the 'Disable Script Debugging' boxes for both IE and other.

when I add a simple function to display an alert in both the site.master and any content view the breakpoint will not fire.

Have i missed something obvious or do I need to use an outside tool for debugging like FireBug?

By the way, I'm using Visual Studio Web Developer Express 2008.

thx

A: 

I don't use VS.Net Express, but in VS.Net Standard you can go to the Debug menu in your solution and choose "Attach to process". You will then get to choose the debug type: Native, Managed, or Script. Select Script, then select your process from the list. A list of scripts will now come up in your IDE. Click on script one you want to debug, throw in a breakpoint or two, and you should be ready to go.

If MS has nerfed the Express version so that you can't attach to a process, then I guess you're stuck and will need the $$$ upgrade (which wouldn't entirely surprise me). Hey, what do you want for free? :)

I don't think it's Express, as pointed out in the post, Javascript debugging works in WebForm app in Express, just not MVC.
Mr. Kraus
A: 

VS JS debugging can work, but... Honestly, get Firebug. It's free, and does much, much more than the VS debugger.

Craig Stuntz
A: 

Here's my workaround for debugging javascript in MVC. VS2008 doesn't pick up on break points for javascript in an aspx page, but it will for a separate .js file. I create a debugJscript.js file when I'm working on a page. I create a reference to that debug page from my aspx page. I can step through javascript that way and then push the javascript code back to the aspx page when I'm happy with it.

You can avoid caching problems, too, on that external .js file if you refer to your file like so:

    <script type="text/javascript" src="../../Scripts/DebugJScript.js?<%=DateTime.Now %>" ></script>
malckier
Keeping your js in a separate file is a better approach in general, not just for debugging.
bmoeskau
+1  A: 
function test()
{
  debugger;
  alert("hi");
}

I don't know if it will work with express, but when IE hits the "debugger" instruction, it asks me if I want to debug, and with wich tool. Visual studio is present in the list of options presented to me.

I don't know if express will be present for you though.

"debugger" also works with firebug.

Jean-Francois
A: 

You can use IE8 or google chrome, for details please see Java script debugging

bimbim.in