Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript breakpoint not work in Visual Studio 2019 asp.net application

I recently upgraded from VS 2017 to VS 2019.

In VS 2017, when running an asp.net application locally, using Chrome, I could put a breakpoint in javascript code and the debugger would stop on the breakpoint. This no longer works in Visual Studio 2019.

What do I need to do to enable javascript debugging in Visual Studio 2019 using Chrome? I would like to be able to put breakpoints in javascript files and have them hit.

Here is my setup.

  1. I've enabled Javascript debugging. enter image description here

  2. I put a breakpoint in my Javscript code. This breakpoint is in a *.js file (not inside a Razor view).

enter image description here

  1. The breakpoint is ignored. Visual Studio very courteously shows me a tooltip telling me the breakpoint will be ignored.

enter image description here

like image 953
Tom Regan Avatar asked Nov 01 '19 13:11

Tom Regan


People also ask

How do I enable JavaScript in Visual Studio 2019?

Click the JavaScript Console, Call Stack, Watch 1, Locals, Output and Breakpoints items in turn so they are all open at the bottom of the Visual Studio window. Activate the JavaScript Console window by clicking its tab.

How do I set breakpoints in Visual Studio 2019?

To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.

Why my breakpoints are not working?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.


1 Answers

It should work in VS2019+Chrome.(I just checked this in several machines)

This is not one issue can be resolved directly since many factors can cause this behavior, you can follow suggestions below to check if it helps:

1.Update your VS2019 to latest 16.3.7, update your chrome browser to latest 78.0.3904.87

2.Delete the bin and obj folders in your project directory => then close and restart VS => open that project and do a clean rebuild

3.Make sure you're in debug project mode, right-click your web project=>Set as StartUp project

Also, sometimes we need to wait for several seconds before the debug session starts successfully.(I once met same popup, then after several seconds it disappeared and everything worked)

Hope it helps :)

like image 175
LoLance Avatar answered Oct 15 '22 18:10

LoLance