Home > Mobile >  VS2019: Debugging mvc code to find the controller/action associated with a button click
VS2019: Debugging mvc code to find the controller/action associated with a button click

Time:11-03

I'm using visual studio 2019 to debug an mvc website. I need to find the action associated with a particular button click but I've been unable to locate this action and I'm trying to determine the best way to locate/trace actions that are being hit when I perform a particular task within the website (in this case, a button click).

The site is a bit convoluted, utilizing combinations of mvc c#/razor syntax, jquery, react, and several other technologies that devs have implemented into the site over the years, and due to this, it's a bit difficult to follow along with, in some areas. In prior jobs, I used Fiddler to locate actions to trace the code, but for reasons I'm not yet sure of, Fiddler doesn't seem to work on this website (I'll also need to look into this later).

So does anyone know any tips to be able to isolate which actions are being called, in this case, when I click a particular button? Is there anything within vs debugging that can perhaps help?

Thanks

CodePudding user response:

Developer menu (F12) -> Network Tab -> Click the button

If it goes to a controller action should be able to tell which controller based on the route.

If it doesn't then it may be a button that calls some javascript, which will be on the source tab of the browser developer menu. You may have to reload the page for the source to show up, then click on the source file.

  • Related