Which action is executing during an HtmlHelper extension method

I'm working on a menu-generating HtmlHelper extension method. This method will need to know which Action is being executed. So if Home/Index is executing, the extension method would show all links to other actions that're "coordinated." In a sense, all I need to know during the execution of the Home controller's Index action is the name of the Controller and the name of the Action that are being executed so that other logic can be executed. Is this possible?

Answers


Try this

var action = HtmlHelper.ViewContext.RouteData.Values["action"];
var controller = HtmlHelper.ViewContext.RouteData.Values["controller"];

Need Your Help

Scaling the the regex backreference

php regex

I need to convert a font-size pt value to a font-size px value. Since I have a 96dpi screen I need to scale up the pt value by 1.33 so that the px value has the same size on the screen as the pt v...

OnClick not firing when using both OnClick and OnClientClick

html asp.net onclick postback onclientclick

I've inherited a system that I'm now trying to alter by adding validation.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.