source code bean

19 Apr, 2010

First steps toward EPiServer and ASP.NET MVC

Posted by: Peter In: ASP.NET|C#|EPiServer|Web

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 Responses to "First steps toward EPiServer and ASP.NET MVC"

1 | Mark Everard

April 20th, 2010 at 10:10 am

Avatar

Great work. I’m really interested to see how this turns out

2 | Pablo

May 14th, 2010 at 1:31 pm

Avatar

What’s EpiServer MVC 5?

3 | Peter

May 21st, 2010 at 6:20 am

Avatar

@Pablo, oops that was a typo. It should of course be EPiServer CMS 5

4 | Dave Bartlett

August 30th, 2010 at 11:29 pm

Avatar

Awesome! It would be great if you could post your prototype. Cheers.

5 | Peter

September 19th, 2010 at 5:13 pm

Avatar

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.

6 | EPiServer – Continuous Integration and Deployment

November 30th, 2010 at 8:28 am

Avatar

[...] site we are building is an EPiServer 6 CMS Enterprise site based on .NET 4.0 and ASP.NET MVC 2.0 (I blogged about it back in April). When we started the project we had very clear goals regarding CI and [...]

Comment Form

About

Welcome to source code bean! On this site I post stuff that I encounter in my job and spare time. The content is mostly related to .NET development, but my interest in techonology is very broad, so often you will find posts on totally different subjects!