views:

8

answers:

0

I’m trying to create my own smart ActionLink htmlhelper that determines if a user is authorized to perform the action that the link points to. If they are not authorized then I want to launch a javascript modal login box to screen.

I have gotten it to work in cases where my method names are all unique. But I need it to be more intelligent and know exactly which of the overloaded Methods will be invoke based on the url and therefore not run into an ambiguous exception. Therefore I need to use the ActionInvoker but I’m not sure how.

Here is what I am trying to do:

string actionLinkUrl = UrlHelper.GenerateUrl(routeName, actionName, controllerName, protocol, hostName, fragment, routeValues, routeCollection, requestContext, includeImplicitMvcValues);

// Use ActionInvoker to return a MethodInfo myMethod based on actionLinkUrl. This is the part I need help on MethodInfo myMethod; //Use ActionInvoker here to initialize MethodInfo based on url

// Find out if AuthorizeAttribute is decorated on the Method. I can do this already. Though maybe there is a better way. bool hasAttribute = myMethod.GetCustomAttributes(typeof(AuthorizeAttribute), true).Length > 0;