mercredi 8 mars 2017

GetCanonicalActions return duplicate some action

I used below code to return all actions in specific controller:

public List<ActionDescriptor> ActionName(string controllerName)
{
    var types =
        from a in AppDomain.CurrentDomain.GetAssemblies()
        from t in a.GetTypes()
        where typeof(IController).IsAssignableFrom(t) &&
                string.Equals(controllerName + "Controller", t.Name, StringComparison.OrdinalIgnoreCase)
        select t;

    var controllerType = types.FirstOrDefault();

    if (controllerType == null)
    {
        return Enumerable.Empty<ActionDescriptor>().ToList();
    }
    var b = new ReflectedControllerDescriptor(controllerType)
        .GetCanonicalActions()
        .ToList();

    return b;
}

But there is duplicate some action in returned list!
For example I have single action named Details in GiftController, But in returned list there is two Details action.
I also tell that I am using T4MVC in my project.
How can I solved this problem?
Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire