-
Notifications
You must be signed in to change notification settings - Fork 15
Getting Started
Getting started with MVC Turbine with your MVC3 project is very easy. Here are the steps:
Step #1.) Add references to the following dlls below:
MvcTurbine.dll
MvcTurbine.Web.dll
The easiest way to do this is to pull them from NuGet. Just search for "mvcturbine" and you can bring it into your project in seconds. You can also download the dlls from Codeplex and add them to your project manually.
Step #2.) Pick an IoC container. Currently, MVC Turbine supports StructureMap, Castle Windsor, Unity, and Ninject. Get the MvcTurbine.[Your IoC container].dll from NuGet or Codeplex.
Step #3.) In your global.asax file, change the inheritance from "HttpApplication" to "TurbineApplication." Don't worry -- TurbineApplication still inherits from HttpApplication, but it adds a few hooks that you'll be able to take advantage of later.
Step #4.) Add a static constructor to your application, and use it to set up your IoC container. Here is an example for someone who is using Unity:
static MvcApplication()
{
ServiceLocatorManager.SetLocatorProvider(() => new UnityServiceLocator());
}
Step #5.) Move the default MVC routing (if you want to use it) to an implementation of an IRouteRegistrator. Here is what the class will look like:
public class DefaultRouting : IRouteRegistrator
{
public void Register(RouteCollection routes)
{
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new {controller = "Home", action = "Index", id = UrlParameter.Optional}
);
}
}
If you'd like to watch a video demonstrating a MVC Turbine setup, check the video below. It is setup for a MVC2 site, but it's the same for MVC3.
http://www.youtube.com/watch?v=1yQ1EFj5gdY