We have a
RouteData object which is a
Dictionary object with two items inside it such as
Controller and
Action which is used to find information regarding Action and Controller.
RouteData object has Value method or we can say we have to pass key name as action and controller.
Below is the code to find Action and Controller Names:-
if (RouteData.Values["controller"] != null)
{
var mvc_controller = Convert.ToString(RouteData.Values["controller"]);
}
if (RouteData.Values["action"] != null)
{
var mvc_action = Convert.ToString(RouteData.Values["action"]);
}