O'Reilly logo

ASP.NET MVC 2 Cookbook by Richard Kimber, Andrew Siemer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a controller factory for use with StructureMap

In this recipe, we will implement our own controller factory, which will allow us to utilize the structure map at the very top of the request cycle of the MVC framework. This will allow us to get rid of any object initialization that we might otherwise have to do directly in a controller. This in turn means that our controllers can conform to a dependency injection style of development, which will make them considerably easier to test.

Getting ready

The first thing we need to do to create a StructureMap controller factory is to download StructureMap here: http://structuremap.sourceforge.net/Default.htm. We will also use NBuilder to make our example a bit more of a real-world scenario. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required