0

In Razor Page Model, breakpoint will not work if we mix that .cshtml or .js file with razor syntax.

But we were still able to insert the debugger keyword to the javascript and it will break.

However this feature is no longer working with the latest :-

  • Microsoft Visual Studio Community 2019 Version 16.9.4
  • Microsoft Edge - Version 90.0.818.39 (Official build) (64-bit)

It will stops at the point when it saw the debugger keyword, but the dynamically generated page (Razor .cshtml) is blank.

s k
  • 4,342
  • 3
  • 42
  • 61

1 Answers1

0

Please first check Enable JavaScript debugging for ASP.NET (Chrome, Edge and IE) option under Tools-->Options-->Debugging-->General.

Then, start debugging and set the breakpoint under the active Script Documents from Solution Explorer. Refer from this official document.

And you cannot automatically hit breakpoints on files generated with Razor syntax (cshtml, vbhtml). You have to try the following ways provided by the document.

If the steps it provided do not help with Edge, I think you should report a problem to the Team under VS menu Help --> Send Feedback --> Report a Problem.

As a suggestion, if my suggestion does not satisfy you, you can ignore it:

You would better not use Razor syntax under JS file. You could use a separate js file and then use write your js file and then import this single js file into cshtml.

Sara Liu - MSFT
  • 6,007
  • 1
  • 21
  • 27
  • Thanks, actually it does break at the ``debugger;`` statement, but the entire page is blank, I can't see the code. – s k Apr 19 '21 at 09:17
  • clean the cache under Edge, also fail? – Sara Liu - MSFT Apr 22 '21 at 09:40
  • Yes, still blank. But I manage to workaround this issue. Set a ``debugger`` statement at the very beginning of the page *(before any element is render, but late enough that I can see the script)*, and then set a breakpoint by pressing f9 after the execution break at the ``debugger`` statement. – s k Apr 24 '21 at 02:23