如何在 cshtml ASP.NET core 中调试 JavaScript 脚本使用 Chrome 浏览器或 Visual Studio 2019?

问题描述

我正在使用 ASP.NET Core,我有 cshtml 格式的 html 页面和 cshtml.cs 格式的 c# 控制器。在 html(cshtml) 页面中,我有一部分代码需要调试。但是当我在 Chrome 中调试时,它显示它是动态加载的,所以看不到它。我怎样才能让它在 Chrome 中显示,或者我应该在 Visual Studio 中调试这个 js 脚本? 这是picture

解决方法

试试看这篇文章: How to debug dynamically loaded JavaScript (with jQuery) in the browser's debugger itself?

我在调试动态加载的 JavaScript 时遇到了同样的问题,只是没有显示如下内容:did not show anything when debugging dynamically loaded JavaScript

当我在 html 页面的 结尾之前添加 //# sourceURL=whatEvertheNameIS.js 时,

html

在 chrome 中调试期间它确实变得可见。 debug in the chrome.