To get the latest build of T4MVC:

Go to MvcContrib T4MVC page on CodePlex


A few weeks back, we announced (mostly on Twitter) that T4MVC was moving into the MvcContrib Codeplex project.  I didn’t say much about it at the time because there wasn’t a whole lot to say yet, in the sense that the move had not actually happened.  MvcContrib was transitioning from github to Mercurial, and since I wasn’t familiar with either one, I figured I’d wait for that and only have to learn Mercurial.

So to make it short, all of this has finally happen, and we can now say that T4MVC is officially part of MvcContrib!  Many thanks to Eric Hexter and Jeremy Skinner for helping make this possible.


So what difference does it make for it to be in MvcContrib?

The download and documentation pages moved to into MvcContrib, but that in itself is not very interesting.  The major difference is that it will now be much easier for anyone to contribute changes, given that the project is completely open source.  Previously, people were sending me suggestions by email, and the whole process was very ad hoc.

Now you can contribute changes the same way you would for the rest of MvcContrib.  Please check out this new instruction page that Jeremy just put together.  If you’ve used Mercurial before, you’ll barely need to read it.  If you have not, then you’ll need to learn the basics.  I found this site by Joel Spolsky to be a great intro.


How to contribute to T4MVC

Check out the T4MVC contributor guide.


What’s new in 2.6.13

In addition to the MvcContrib move, T4MVC 2.6.13 brings in a few new features.

Support to include an optional timestamp query string in the static file links

This idea came from Wayne Brantley.  From T4MVC.settings.t4:

// If true, links to static files include a query string containing the file's last change time. This way,
// when the static file changes, the link changes and guarantees that the client will re-request the resource.
// e.g. when true, the link looks like: "/Content/nerd.jpg?2009-09-04T12:25:48"
const bool AddTimestampToStaticLinks = false;

By default, this is turned off, so switch the flag if you want to use it.


Added support to recognize the [Bind(Prefix=”…”)] attribute

This one was suggested by Kris Penner.  Suppose you have an action that looks like this:

public virtual ActionResult ActionWithBindPrefixAttribute([Bind(Prefix = "newParamName")] string fieldName) {

What this means is that this parameter needs to get sent as ‘newParamName’ instead of ‘fieldName’ in the route values.  Previously, T4MVC was ignoring this and basically doing the wrong thing.  Now, calling MVC.MyController.ActionWithBindPrefixAttribute("Hello") will correctly generate a route value that has newParamName=”Hello”.


New way to easily add all the query string values to the route

Another Wayne Brantley Idea (he keeps me busy! :)).  Suppose you want to add all the current query string values to the route values produced by T4MVC.  You can now use a new AddRouteValues() overload that takes a NameValueCollection.  e.g.

This adds to the existing set of AddRouteValue/AddRouteValues fluent APIs to make it easier to deal with all kind different situations.


New MapRoute overload that supports constraints

This was just a missing overload that’s needed when you use T4MVC in your route and happen to also need some constraints.  Here is the overload:

public static Route MapRoute(this RouteCollection routes, string name, string url, ActionResult result, object defaults, object constraints);


Removed some VS2010 Beta 2 specific logic

There was some transitional logic that only made sense in beta 2, so I yanked it since everyone should be using VS2010 RC or later now.  Note that T4MVC still works fine on VS2008 SP1, and works with both MVC 1 and MVC 2.  It’s only support for the old 2010 Beta 2 that’s being removed to clean things up.