I just installed Visual Studio 2017. After starting an ASP.NET MVC application I get the message that chrome debugging in Visual Studio is enabled.
But my breakpoint
Two options you could try:
Solution Explorer -> Internet Explorer -> <your view name>
. (Assumes you are using IE)After thinking the only way to get this working was to do a repair on Visual Studio 2017, using the installer, I realized that we had BundleTable.EnableOptimizations = true;
in Bundle.config
. I removed this line and added it to Web.Debug.config
transformation and it started working as expected.
I had to enable Legacy Chrome JavaScript debugger under:
Options -> Tools -> Debugging -> General -> Enable legacy Chrome JavaScript debugger for ASP.NET
My best guess here (at least in my case, potentially in your case as well) is that it has to do with bundling. The project I'm working on right now bundles separate scripts into one Big Daddy script (without minifying in debug configuration) so my hunch is that VS won't map my breakpoint to that ultimate script run in the browser.
I know this doesn't answer the question since it's just a hunch, but I'm hoping it points us in the right direction. Maybe if we can validate this against others' experience this could evolve into a real answer.
This feature does not work for javascript code inside a *.cshtml file, but only for code in separate *.js (or *.ts) files.
Notice how the breakpoint in the JavaScript file is active, while the breakpoint in the Razor view is not.
I have also noticed that breakpoints will not be hit for JavaScript files when JavaScript code is executed during page load when the page is loaded the first time in the current Chrome session. Breakpoints will only work after the document has finished loading once.
I finally got all my break points to begin hitting after I right clicked on IIS Express and Exit after working for many hours.
I had debugger in my script files and break points and as soon as I did a Clean Solution > Debug my breakpoints started to begin to hit again.
I understand how frustrating this is and I am just letting the stackoverflow community know what worked for me.