Tags : asp-net-mvc
Often there will be a requirement to determine the names of the Controller and Action in ASP.NET MVC (such as from within a View). The RouteData object is a dictionary with two items - 'controller' and 'action' which exposes this information.
var controller = RouteData.Values["controller"].ToString();
var action = RouteData.Values["action"].ToString();
blog comments powered by Disqus