In ASP.NET 4.x, there is a ReflectedControllerDescriptorclass which resides in System.Web.Mvc. This class provides the descriptor of a controller.
In my previous applications, I used to do this:
var controllerDescriptor = new ReflectedControllerDescriptor(controllerType);
var actions = (from a in controllerDescriptor.GetCanonicalActions()
let authorize = (AuthorizeAttribute)a.GetCustomAttributes(typeof(AuthorizeAttribute), false).SingleOrDefault()
select new ControllerNavigationItem
{
Action = a.ActionName,
Controller = a.ControllerDescriptor.ControllerName,
Text =a.ActionName.SeperateWords(),
Area = GetArea(typeNamespace),
Roles = authorize?.Roles.Split(',')
}).ToList();
return actions;
The problem is I can't find any equivalent of this class in ASP.NET Core. I came across IActionDescriptorCollectionProviderwhich seems to provide limited details.
The Question
My goal is to write an equivalent code in ASP.NET Core. How do I achieve that?
Your help is really appreciated
IActionDescriptorCollectionProviderand using that to retrieve the desired instances ofControllerActionDescriptoras described here