Leonhart 27
Leonhart 27

Reputation: 101

ASP MVC Get Controller/Action Name?

In ASP.NET MVC, how can I get the controller/action name base on request URL?

Url example: http://contoso.com/View/Comment/1

I want to get:

Based on HttpContext.Current.Request.

Upvotes: 1

Views: 4041

Answers (1)

SLaks
SLaks

Reputation: 887433

You need to use the parsed information from the routing engine:

ViewContext.RouteData.GetRequiredString("action")

Upvotes: 6

Related Questions