问题描述
我刚刚安装了 Visual Studio 2017.在启动 ASP.NET MVC 应用程序后,我收到消息说 Visual Studio 中的 chrome 调试已启用.
但我在 Visual Studio 中的断点不会命中.Razor 代码上的断点似乎可以正常工作,但 Javascript 不能.断点没有像应有的那样完全变红.重新启动,重建似乎没有任何效果.
我有以下代码示例
@Html.Partial("_Test", Model.Test)//调试工作在这里<脚本>变量 i = 1;控制台.log(i);//调试在这里或上面不起作用</脚本>@section 脚本 {<脚本>变量 a = 11;控制台.log(a);//调试在这里或上面不起作用</脚本>}我没有打开 chrome 调试控制台,我检查了 Visual Studio 中已启用的选项('启用 Javascript 调试..').
根据这篇博文,我认为这应该可行:注意 JavaScript 文件中的断点是如何激活的,而 Razor 视图中的断点不是.
我还注意到,在当前 Chrome 会话中第一次加载页面时,在页面加载期间执行 JavaScript 代码时,不会为 JavaScript 文件命中断点.断点仅在文档完成加载一次后才起作用.
I just installed Visual Studio 2017. After starting an ASP.NET MVC application I get the message that chrome debugging in Visual Studio is enabled.
But my breakpoints in Visual Studio won't hit. The breakpoints on Razor code seems to be working but Javascript does not. The breakpoints are not fully red like they should be. A restart, rebuild don't seem to take any effect.
I have the following code example
@Html.Partial("_Test", Model.Test) // debugging works here
<script>
var i = 1;
console.log(i); // debugging does not work here or above
</script>
@section scripts {
<script>
var a = 11;
console.log(a); // debugging does not work here or above
</script>
}
I don't have the chrome debugging console open and I checked the option in Visual Studio ('Enable Javascript debugging..') which is enabled.
According to this blog post I thought this should work: https://blogs.msdn.microsoft.com/webdev/2016/11/21/client-side-debugging-of-asp-net-projects-in-google-chrome/
Am I missing something here? Could it be that this is not working in Visual Studio 2017 somehow?
I only have one extension and that is Resharper, but I guess this is not an issue.
This feature does not work for javascript code inside a *.cshtml file, but only for code in separate *.js (or *.ts) files.
Notice how the breakpoint in the JavaScript file is active, while the breakpoint in the Razor view is not.
I have also noticed that breakpoints will not be hit for JavaScript files when JavaScript code is executed during page load when the page is loaded the first time in the current Chrome session. Breakpoints will only work after the document has finished loading once.
这篇关于Visual Studio 2017 中的 Javascript 断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)