Reputation: 101
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
Reputation: 887433
You need to use the parsed information from the routing engine:
ViewContext.RouteData.GetRequiredString("action")
Upvotes: 6