How to check what controller and method are called?
In html in body tag there is: <body id="somethingThatDependsOnControllerAndMethod">
. id
value will be assigned based on controller and it's method.
How to check what controller and method are called?
In html in body tag there is: <body id="somethingThatDependsOnControllerAndMethod">
. id
value will be assigned based on controller and it's method.
Check out my answer to this question. It describes how to get the info you need within your controller and then you can pass that info down to your view using a view model or the ViewData property bag.
I prefer this method, because it gives my view everything it needs to do it's job. I also don't like using the ViewContext, because it means I have to use strings to access it's dictionary for what I need and I prefer to keep everything strongly typed.
I have this in my MasterPage to get this info to display certain things on-screen, might help with the info you need (might not be the most elegant solution)
public string ControllerActionName
{
get
{
return String.Concat(ViewContext.RouteData.Values["Controller"], ViewContext.RouteData.Values["Action"]).ToLower();
}
}