I've create a base-controller and I'm trying to acquire in its BeginExecuteCore the action method that is associated.
Basically I need to check if an action/method has a [ChildActionOnly] Attribute. I know that I could use:
RouteData.Values["action"] as string
but this will cause issues in case there are actions with the same name (i.e. get,post), it will throw this exception when calling reflection based on a method name:
System.Reflection.AmbiguousMatchException
Thus, how can I implement a method to be called in BeginExecuteCore to check if the action has a specific attribute? This is how I would like to call the method (_IsActionChildActionOnly), I need Its implementation:
protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
{
if(_IsActionChildActionOnly() == true) //<---function call
{
//... do other stuff
}
return base.BeginExecuteCore(callback, state);
}
private bool _IsActionChildActionOnly()
{
//How can implement this method?...
//Check if action has attribute...
}
If what I'm trying to achieve is not possible or my approach is wrong, please let me know if there are any other solutions.
Aucun commentaire:
Enregistrer un commentaire