Snippet Fire

Beta
 Log In    |   Sign Up

.NET : Find Action and Controller Names in ASP.NET MVC

Added on Jan-11-2012 by admin
For .NET

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.

DOWNLOAD

var controller = RouteData.Values["controller"].ToString();
var action = RouteData.Values["action"].ToString();

    

Report Snippet

blog comments powered by Disqus