【发布时间】:2017-03-08 10:45:05
【问题描述】:
我刚刚安装了 Visual Studio 2017。启动 ASP.NET MVC 应用程序后,我收到消息说 Visual Studio 中的 chrome 调试已启用。
但我在 Visual Studio 中的断点不会命中。 Razor 代码上的断点似乎可以正常工作,但 Javascript 不能。断点没有像应有的那样完全变红。重新启动,重建似乎没有任何效果。
我有以下代码示例
@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>
}
我没有打开 chrome 调试控制台,我检查了 Visual Studio 中已启用的选项('启用 Javascript 调试..')。
根据这篇博文,我认为这应该可行: https://blogs.msdn.microsoft.com/webdev/2016/11/21/client-side-debugging-of-asp-net-projects-in-google-chrome/
我在这里遗漏了什么吗?难道这在 Visual Studio 2017 中不起作用?
我只有一个扩展,那就是 Resharper,但我想这不是问题。
【问题讨论】:
-
你做得比我好。在 JavaScript 中使用断点的选项甚至不可用。
-
如果您以管理员身份运行 Visual Studio 15.9.12 并尝试在 javascript 代码中放置断点,即使在 .cshtml 文件中,它也会自动弹出一个窗口,要求您启用 JavaScript 调试。 Visual Studio 'JavaScript debugging warning' pop-up window 但是,至少对我来说,即使它现在到达断点,我也无法通过将鼠标悬停在变量上(弹出窗口根本不会显示)或将它们添加到监视窗口(它会出错)来检查变量带有 `error CS0103: The name of 'variableNameHere' does not exist in the cur
标签: javascript visual-studio visual-studio-2017