0

I am developing an ASP.NET application, and sometimes it's a consuming time process to find the exact line of code that will execute at the server after the user makes an action in a form (clicking somewhere,writing, moving the mouse, etc): You've to guess where to put a breakpoint for the debugger to stop.

I know I can manually set breakpoints in the controller, or in the Load() events, etc. But I'd like to have a 'friendly advice' from VS (call me lazy)

My question is: In Visual Studio, can you 'tell' it: "Hey Visual Studio, good boy... Would you please stop the execution at the first instruction at the server ? I don't know what will be executed, but as you are smarter than me, I want you to show me that magic line, and stop at it, would you please?".

Thanks in advance,

Roger

Roger
  • 333
  • 2
  • 13
  • 1
    Not that I'm aware of. But you're free to place System.Diagnostics.Debugger.Launch statements in your code (I usually remove them when done and don't commit them to source control). I don't know if this will work with a remote debugger, but it works well enough when the app is on the same machine in my experience. Armed with that, and a little knowledge about where the first bits of your code are that are executed (such as Program.cs or Startup.cs in ASP.NET Core, or Application_Start event in ASP.NET) this can be very useful to debug startup issues. – mason Mar 22 '23 at 12:49
  • 1
    You can add a DebugMiddleware that just calls the next one and place a breakpoint there. Or use something like ELMAH and look which controller got hit. – CodeCaster Mar 22 '23 at 12:53
  • See https://stackoverflow.com/questions/73041905/visual-studio-2022-find-the-next-line-of-code-to-execute – Sergey Vlasov Mar 23 '23 at 02:44

1 Answers1

0

At first I wanted to use regular expressions to simulate the names of all events at the breakpoint of the new function, but regular expressions don't seem to be supported there.

But since you are using ASP.Net, you can use Google Chrome or Firefox to add breakpoints to JavaScript events. You can refer here. Or add a breakpoint to the method that receives the front-end event, you can refer to here.

Hope to be of some help to you

sssr
  • 364
  • 1
  • 6