Can someone explain to or link to an article that explains how the parameters passed into the action of a controller are populated? I understand the basic mapping when you have the Controller/Action/ID and the ID is passed in as a variable, if it doesn’t convert to the type that you are asking for then it won’t be passed in to that action.
However I have been looking at the MVCContrib sub controller code and there was the following example:
public ActionResult Index(FirstLevelSubController firstLevel)
I want to know how this parameter is being populated because as far as I know nothing is being passed in to populate this?
Let’s say I created the following action which is the only action in the controller:
[AcceptVerbs(HttpVerbs.Get)] public ActionResult Index(Task task, ToDoList list)
What would I be passed back and why? (I know I could do a quick test to find out if they did come back but that would make me non the wiser as to why.
Thanks
Generally, its a function of ControllerActionInvoker. Objects are passing into the action after they instantiated in custom ControllerActionInvoker implementation. For more info about how ControllerActionInvoker works take a look at ASP.NET MVC – ControllerActionInvoker: Part 1
Also there is a feature called ‘model binding’, that helps you to bind the request params to your objects, so in most cases you do not need to make your own ControllerActionInvoker implementation. Take a look at this: ASP.NET MVC model binding from ScottGu