T4MVC for MVC
If your using MVC then please at least take a look at T4MVC or better still add it to your project from Nuget here T4MVC from Nuget – It’s written by David Ebbo who works for Microsoft and works on Nuget as well as a lot of other cool stuff.
What is T4MVC? – the following is lifted from the documentation:-
“T4MVC is a T4 template for ASP.NET MVC apps that creates strongly typed helpers that eliminate the use of literal strings when referring the controllers, actions and views. It helps make your MVC code much more maintainable, and gives you intellisense where you normally would not have any.”
Some links for more info:-
An example again lifted from the site would be:-
[sourcecode language=”csharp”] @Html.RenderPartial("DinnerForm");[/sourcecode]
Now becomes
[sourcecode language=”csharp”] @Html.RenderPartial(MVC.Dinners.Views.DinnerForm);[/sourcecode]
and you get Intellisense for free which is nice.
Also this
[sourcecode language=”csharp”] @Html.ActionLink("Delete Dinner", "Delete", "Dinners", new { id = Model.DinnerID }, null)[/sourcecode]
becomes this
[sourcecode language=”csharp”] @Html.ActionLink("Delete Dinner", MVC.Dinners.Delete(Model.DinnerID))[/sourcecode]
The beauty of this needs to be tried to ge the full extent of whats available but its really easy to add in and change your links in a flash.
By the way it even works for images so heres an example using the aspx syntax.
[sourcecode language=”csharp”] <img src="/Content/nerd.jpg" />[/sourcecode]
becomes
[sourcecode language=”csharp”] <img src="<%= Links.Content.nerd_jpg %>" />[/sourcecode]
T4MVC is very handy indeed and you should definitely check this out.