Given I have access only to ControllerContext
and not Action____Contexts
what is the optimal way to get the current executing ActionDescriptor?
So far the only method I've found is:
new ReflectedControllerDescriptor(context.Controller.GetType())
.FindAction(context, context.RouteData.GetRequiredString("action"));
Is this the optimal method?
The fact that class is named ReflectedControllerDescriptor
leads me to wonder if there is a heavy cost to this operation as it will be executed on every page request? Related to that is does this class internally cache or should I actually be caching ReflectedControllerDescriptors
explicitly?
ReflectedControllerDescriptor
is indeed cached, but arguably I could cache my calls to FindAction? – Strophic