Building up an MVC application

When you open up MVC out of the box, you get the basic configuration, after a little playing around you soon see areas that require enhancing to, not only make your application more flexable, but also easier to maintain.

Here are a number of additional tasks you can perform that will help with your application.

Which IoC to use?

Don’t worry, if you use the Common Service Locator it provides an adstraction over the IoC

How to validate?

I have already covered this one in a previous post, but I’d still go with xVal

Need to generate Themes?

I think it is so important to start correctly and generating the User Interface should be configurable, the easiest way of doing this is to implement a Theme, and Chris Pietschmann has do this for us, Implement Theme Folders using a Custom ViewEngine

Here is a copy of the source for safe keeping. (226.05 kb)

Need Ajax to work in MVC

Ajax.BeginForm and PartialViews

Extend the UrlHelper


Placing all your assets in one place is not only a good idea, but it also means you can be more flexable if you want to programmically change the theme of your user interface.



Which can be used like this:

Using Strongtypes and keep away from Strings

It appears so easy with MVC to use String everywhere, just DON’T, generate an extension for the UrlHelper

Now in your view it will look like this


I’ve been hit before by Microsofts in build Testing within Visual Studio 2008, great to have this feature built in, BUT, and a big but in order to run the tests you need to have Visual Studio install, so if you try and setup a Continuous Integration server you will also be required to install Visual Studio.

So best to go with what works well and that is nUnit, simple and easy, and more importantly loosely coupled


With testing comes Mocking, and which framework do you use?  I also always say keep it simple and easy, so I’m going with Moq, short for “Mock-You”, as this is the only Mock Framework that is built around .Net 3.5 and LINQ.