Monday, February 27, 2012

Get action name in view


If you want the name of the controller, action or the route values in your ASP.NET MVC view, this is how.
ViewContext.Controller.ValueProvider["action"].RawValue
ViewContext.Controller.ValueProvider["controller"].RawValue
ViewContext.Controller.ValueProvider["id"].RawValue
Source: http://stackoverflow.com/questions/362514/how-can-i-return-the-current-action-in-an-asp-net-mvc-view

No comments:

Post a Comment