I would like to design a model with some way of specifying a Controller Action to be used for searching. I do not want to specify the action's url as a string because I do not want the app to compile if that action does not exist.
From what I can tell, it seems like I should specify a property of type System.Web.Mvc.ActionDescriptor
like so:
public class myModel {
public string id { get; set; }
...
public ActionDescriptor search_action { get; set; }
}
From this SO post I see how to get iterate through all actions on all controllers but I'm having trouble instantiating an ActionDescriptor
to set the property.
I was hoping to be able to do some variation of this:
myModel m = new myModel();
m.search_action =
(ActionDescriptor)new myNamespace.Controllers.myController().myAction;
but didn't get anywhere.
Am I missing something? How do you specify a Controller Action as a property of a model? Is this even possible?