First steps toward EPiServer and ASP.NET MVC

Recently I started a new assignment at a customer where we are going to build their new public web site and their intranet, both of them based on EPiServer CMS 6. The person leading the project is very found of ASP.NET MVC, so my first task was to experiment with EPiServer and ASP.NET MVC, to try to get a running prototype up.

I did some research online to see what others had done. I found two great posts by Joel Abrahamsson and one from Fabio Fabrizio, who based his solution on Joels experiments.

Joels first attempt was to create a base class from which all Controllers inherited. However, this made the controller do more than it should and made it very hard to test. His second attempt was to create a custom model binder and make every action receive currentPage as a parameter. This approach makes it much easier to create unit tests for the code, since it is now possible to moc the currentPage parameter.

Fabio took a different approach and decided to implement a custom MVC handler and a controller factory. This approach fits very well with MVC and felt like the right way to go, so I decided to create a prototype based on Fabios code. Fabios code was based on EPiServer CMS 5 and ASP.NET MVC 1.0, but I wanted to use EPiServer 6 and ASP.NET MVC 2.0, so I started porting the solution.

Porting the solution to EPiServer 6 and ASP.NET MVC 2.0 required some changes to both code and configuration, which not all of them was trivial. At the moment I have a prototype up running, and it works remarkably well! I will continue my experiments and post my results.


6 thoughts on “First steps toward EPiServer and ASP.NET MVC

  1. At the moment I can not post any code, but I can give you a short update on the status of the project. The prototype was very successful and the customer has decided to build their new platform for web and intranet onto of it.


    The trickiest part getting MVC working was probably getting EPiServer running side by side with MVC 2. EPiServer internally uses MVC 1.0 for some stuff, for example the new dashboard and the reporting services. To solve this we had to create a custom build of MVC 2 (thank god for open source!) in which we give MVC 2 a custom namespace.


    In addition to ASP.NET MVC we are using PageTypeBuilder for statically typed pages, Autofac as IoC container to di DI, NUnit for unit testing, Cucumber for integration testing, fully automated deployment using WebDeploy and Powershell and TeamCity for CI. Overall an exciting project 🙂


    We have been discussing releasing our MVC add-on to EPiServer as open source when we feel it is mature enough, but nothing is decided yet.

Leave a Reply

Your email address will not be published. Required fields are marked *