Visual Studio 2013 can't debug javascript in cshtml

不问归期 提交于 2019-11-28 20:05:51

So, apparently this is a "known issue" that will be fixed as soon as possible. A temporary work around that works for "some" people is making sure any Javascript is in a separate file.

It is caused by having RAZR and Javascript in the same file and Visual Studio 2013 not being able to handle debugging in that instance.

I don't know what your particular problem is, but if you want to force a debug breakpoint to always happen, add debugger; to the line that you want it to stop on, and it will stop. This is regardless of where the JS is located (in a .js file, .html, cshtml, etc.)

Here is a blog post about it:

http://sumitmaitra.wordpress.com/2013/12/11/quickbytes-visual-studio-2013-and-javascript-debugging/

I also agree that JS should go in a .js file (which I've never had a problem adding a break point in a .js file), but for quick prototyping, this is a solution you can use.

If that still doesn't work, you can always you the F12 tools

The only browser that allows debugging a javascript file from Visual Studio is Internet Explorer. (this is what I found out after testing my application on different browsers)

I put my javascript in a separate file and debug with IE otherwise it will not work.

For some reason chrome doesnt allow you to step into the javascript.

One additional thing to check. If you have a App_Start|BundleConfig.cs (which came with MVC 4 - or maybe 3), set BundleTable.EnableOptimizations to false (or, like I did, wrap it in an #if !DEBUG #endif and take the default setting).

I tried and failed to use Chrome and then IE and ended up using the Firebug addon in Firefox, and I was able to debug and set breakpoints in my JS with no problems (in an MVC6 app on Visual Studio 2015 where this is apparently still an issue?!)...

FYI - When I tried to debug my JS in Chrome using the F12 Developer Tools, it told me it was not an option as the Debugger was already attached to another process...

For people coming here in 2017, I want to share that I had this same issue with VS2017 Enterprise RC, and with VS 2015 Community with any browser but Internet Explorer. Using IE did the trick for me.

Also, in VS2017, I had to add a debugger statement to get VS start looking at debug points.

Finally, I'd like to ask at least a comment from people voting down.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!