Rajithakba
Rajithakba

Reputation: 155

How to access the MVC "action" from the current request?

Is there a way to retrieve the current routing action from a MVC request?

Cheers,

raj

Upvotes: 1

Views: 97

Answers (1)

Jan Zich
Jan Zich

Reputation: 15333

In general, all route values are stored in RouteData. If you want to know it in a view, you use:

<%= Html.ViewContext.RouteData.Values["action"] %> 

If you are in a controller, you use:

string action = RouteData.Values["action"];

Am I answering your question?

Upvotes: 3

Related Questions