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

asked Apr 25, 2020 at 3:05

1 Answer 1

3

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

answered Apr 27, 2020 at 10:25
Sign up to request clarification or add additional context in comments.

1 Comment

Can you provide a small example

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.