Search code examples
asp.net-mvcfubumvc

Tweaking asp.net mvc


I really love the "one model in - one model out" idea of Fubu MVC. A controller would look something like this

public class MyController
    {
        public OutputModel MyAction(InputModel inputModel)
        {
            //..
        }
    }

and the service locator would automagically fill in all the required dependencies in the constructor.

This makes the controller very easy to test.

So my question is: How would you go about tweaking asp.net mvc to allow this simplicity in the controllers ?


Solution

  • What you're looking for the is the ControllerActionInvoker. You'll have to implement your own and override/take over handling a lot of the pipeline work that ASP.NET MVC.

    For reference, check out Jonathon Carter's 2-part post on doing ControllerActionInvokers: http://lostintangent.com/2008/07/03/aspnet-mvc-controlleractioninvoker-part-1/

    and

    http://lostintangent.com/2008/07/07/aspnet-mvc-controlleractioninvoker-part-2/

    Also, the Oxite team did this in the 2nd release of Oxite, you can check out their source here:

    http://oxite.codeplex.com/SourceControl/changeset/view/30544

    Here's a link directly to their ControllerActionInvoker implementation: http://oxite.codeplex.com/SourceControl/changeset/view/30544#442766