Setting up a DD4T 2.0 web application

One of the new features available in the new version of the popular framework DD4T is the modular packaging structure, dividing the framework into smaller packages. This allows the consumer of DD4T to install only the required packages. In this post we describe the steps required to set up set up a DD4T 2.0 web application in Visual Studio.

At the start of a DD4T 2.0 powered web application, the following should be decided.

  • Version of ASP.NET MVC (available ASP.NET MVC 4 and ASP.NET MVC 5)
  • Dependency Injection Container (Autofac, Ninject or Unity)
  • Tridion provider version (available Tridion 2011 SP1, Tridion 2013 and Tridion 2013 SP1)

for this project we will use ASP.NET MVC 5, Autofac and Tridion 2013 SP1, let’s start:

The first step is to create an empty ASP.NET MVC project in Visual Studio.

  1. Start a new Visual Studio project and select “ASP.NET Web Application” template
  2. Select in the second wizard “Empty” template enable the “MVC” option
  3. Install DD4T.MVC 5 Nuget package
  4. Install DD4T.DI.Autofac Nuget package
  5. Install DD4T.Providers.SDLTridion2013Sp1 Nuget package
  6. Install Autofac.Mvc5 Nuget package
  7. Install log4net Nuget package
  8. Copy the Tridion configuration and Content Delivery libraries to the bin folder of the web application
      • \Config folder
      • \Lib folder
      • netrtsn.dll
      • Tridion.ContentDelivery.AmbientData.dll
      • Tridion.ContentDelivery.Configuration.dll
      • Tridion.ContentDelivery.dll
      • Tridion.ContentDelivery.Interop.dll
      • xmogrt.dll
  9. add a reference to Tridion dll’s in Visual studio.
    • Tridion.ContentDelivery.AmbientData.dll
    • Tridion.ContentDelivery.Configuration.dll
    • Tridion.ContentDelivery.dll
    • Tridion.ContentDelivery.Interop.dll

The required DD4T packages, Tridion libraries and configuration installed into the web application. The next step is to wire up DD4T to the web application and set up the correct routes to the DD4T PageController.

1. Open RouteConfig.cs, located in the App_start directory, and add the following Route to the RouteCollection:

2. Open global.asax and wire up DD4T and set DependencyResolver:

3. As configured in Route config, all URLs will be routed to PageController’s Page action. Create a new controller “PageController”

Solution on GitHub: https://github.com/sshibani/DD4T.ExampleWebsite

Accelerate Tridion development and become an expert in DD4T with Trivident’s 2-day in-depth training course.