Getting Started with T4MVC

This post is about T4MVC and how you would use it within your MVC application. T4MVC is a great way to generate strongly typed helpers so you can eliminate the use of literal strings when referring to Actions, Controller, and Views within your MVC application.

How to install T4MVC?

You have 2 options.

a.    Download from MvcContrib CodePlex project.

b.    Use NuGet


NuGet Approach      

Open VS2010. Tools,  Library Package Manager, and Package Manager Console. Execute the following command.

PM> install-package T4MVC

This should install 2 files under your app’s root folder. and – These files contain necessary entries which allow you to use T4 strongly typed helpers.


Once you install T4MVC, you might also notice couple errors appeared in the Error List window. (Please see below)  image

As you see, there are no auto generated files being added to the solution yet. You would continue to get these errors if you decided to build the solution.

To remove these errors, you need to run Custom Tool on the file. (Right click on the file and select “Run Custom Tool”).Now you should be able to see additional auto generated files added to the solution.


T4MVC in Action

Below are few examples of the usage of T4MVC.

image (1)


As you see T4MVC generates the strings accordingly.

Where to find more information?

T4MVC templates are part of MVCContrib project and developed by David Ebbo. If you would like to know more information please visit the link below.


Few years back, Phil Haack introduced a Routing Debugger. You might have also seen this niceMvc Route Debugger Visualizer.

What I’m about to show you is a really cool tool, which allows you to debug ASP.NET MVC applications. It is called Glimpse. Glimpse includes not only route debugging support but also many other features. As you know Firebug is a debugging tool for client, and Glimpse does it for the server. Glimpse only works with the version MVC3. It can support MVC2, however you need to have MVC3 installed. It should support ASP.NET Web Forms as well but the current release (beta version) has dependencies to MVC.  I haven’t tried the Glimpse Web Forms debugging yet, but it is supported.


PM> Install-Package Glimpse









You can configure Glimpse by navigating to


Below is how you see Glimpse while debugging information.


You can debug : Application settings, routes, session variables, trace data.

If it is an Ajax request, then the server embeds the JSON in the content of the page. And many more…

You can see a nice video and more information here.

So if you haven’t started using this, I suggest you download it, as it will definitely assist your development work!