Is it possible to find out from which controller method the view is called?

  • 2
    You can pass information about the controller method to the view. Through the model, through the Viewbag / ViewData ... somehow in general. - DreamChild

1 answer 1

In the view, you can use the ViewContext

 <p> Controller - @ViewContext.RouteData.GetRequiredString("controller") </p> <p> Action - @ViewContext.RouteData.GetRequiredString("action") </p> 
  • The question is slightly different. The controller has a method that returns a view. I call this method from the same controller, but from another method. - Vivus
  • Sorry). There is no difference. Thanks for the help. - Vivus