Get the name of Controller and Action method in View using Asp.Net MVC
In one of my Asp. Net MVC project, I needed the name of the Controller and the Action Method in the View page.
For this I used the following code:-
@{
var actionMethod = @ViewContext.Controller.ValueProvider.GetValue("action").RawValue;
var controllerName = @ViewContext.Controller.ValueProvider.GetValue("controller").RawValue;
}
This solved my problem.
Hope it helps... Happy Coding!
0 Comment(s)