is any better way to find controller name from masterpage view in asp.net mvc?
thanks achu.
is any better way to find controller name from masterpage view in asp.net mvc?
thanks achu.
StackOverflow - Getting the name of the controller and action method in the view in ASP.NET MVC:
<%: ViewContext.RouteData.Values["Controller"] %>
<%: ViewContext.RouteData.Values["Action"] %>
Better than what? The master page should have a ViewContext which allows you to get the RouteData. You should be able to get the name of the controller and action from the RouteData, using the "controller" and "action" keys.
In MVC 4.0 Handle like below.
Controller: @ViewContext.RouteData.Values["Controller"]
Action : @ViewContext.RouteData.Values["Action"]