|
|
Note: This documentation is for the MIX '08 ASP.NET MVC implementation ('Preview 2'.)
Getting the Code
To use System.Web.Mvc, AKA ASP.NET MVC, AKA MS-MVC, you need to install the CTP from http://asp.net/downloads/3.5-extensions/.
Project Integration
Your ASP.NET MVC web application must reference Autofac.dll, Autofac.Integration.Web.dll and Autofac.Integration.Web.Mvc.dll.
The application must include the ContainerDisposal HTTP module and IContainerProvider implementation in Global.asax that are described on the ASP.NET integration page.
Registering Controllers
You can register controllers by hand, using named registrations:
builder.Register<HomeController>().Named("home").ContainerScoped();The Autofac integration will convert all controller names to lowercase before retrieving them from the container (you can customise this through IControllerIdentificationStrategy.)
An easier way to register controllers is using AutofacControllerModule, which searches the provided assemblies for implementations of IController:
builder.RegisterModule(new AutofacControllerModule(Assembly.GetExecutingAssembly()));
Installing into ControllerBuilder
The AutofacControllerFactory class ties the container provider into the ASP.NET MVC ControllerBuilder (in the Application_Start() method of the app class):
ControllerBuilder.Current.SetControllerFactory(new AutofacControllerFactory(_containerProvider));
Sign in to add a comment

Just wondering how hard it would be to update this to Preview 3 of asp.net mvc