1

This blog: Debug JavaScript in Microsoft Edge from Visual Studio https://devblogs.microsoft.com/visualstudio/debug-javascript-in-microsoft-edge-from-visual-studio/ describes how VS is supposed to debug javascript.

It looks great. However, I cannot get it to work. I have a .Net Core 3.1 Razor project.

In IE, Edge, Edge Beta, and Chrome I cannot get the script debugger to work. I have uninstalled all my Visual Studio versions. I have re-installed VS 2019 Community, 16.5.4

My breakpoints always look like this:

enter image description here

jlo-gmail
  • 4,453
  • 3
  • 37
  • 64

1 Answers1

2

Visual Studio javascript debugging not working

I am afraid that you cannot get what you want in cshtml file. As this similar issue said, you cannot debug js code in cshtml file and only for code in separate xxx.js (or xxx.ts) files.

Solution

Instead, you should create a new js file and then migrate these js code into this file and then it should work.

And when you debug your project and load this cshtml page, the breakpoint will not appear and when you finish loading the page, then the breakpoint will appear. And this is the cshtml feature.

Update 1

1) When I try to create a new asp.net core project and then add js code in Viewstart.cshtml file, it will not be hit during debugging.

To prove it, l create a new single js file and migrate the js code into it.

After that, reference this js single in cshtml file and then it will be hit during debugging.

enter image description here

Mr Qian
  • 21,064
  • 1
  • 31
  • 41