Asp.net mvc - Check which controller and method is being called?

How to check which controller and method are called?

The html tag in the body tag is: <body id="somethingThatDependsOnControllerAndMethod">. The value idwill be assigned based on the controller and its method.

+3
source share
2 answers

I have this in my MasterPage, to get this information, to display certain things on the screen, it can help with the information you need (maybe not the most elegant solution)

 public string ControllerActionName
        {
            get
            {
                return String.Concat(ViewContext.RouteData.Values["Controller"], ViewContext.RouteData.Values["Action"]).ToLower();
            }
        }
+1
source

question. , , , , ViewData.

, , . ViewContext, , , , , .

+2

Source: https://habr.com/ru/post/1747352/


All Articles