With ASP.net MVC, one thing I always wondered is why we still had to have the code behind files. Looking at the FubuMVC samples, everything looks much cleaner without the additional files – with RC1, code-behind files are no longer required!
However, if your upgrading from beta, you will need to change your ASPX pages. In this post, I will cover the steps I went through to remove these files.
During beta, my solution looked looked like this:
In my code behind, I have a mixture of strongly typed ViewPage
With RC1, I can remove the CodeBehind tag and replace the Inherits to System.Web.MVC.ViewPage directly.
I can now delete Index.aspx.cs and Index.aspx.designer.cs leaving me with just the Index.aspx file.
If my ViewPage was strongly typed with a model, the the Inherits tag would include this, just like with the code behind model:
For ASP.net MVC User Controls, instead of ViewPage
Similarly with Master Pages:
After changing all my views, controls and master pages, my solution looks like this:
This makes me happy.
UPDATE: Parser Error Message: Could not load type ‘System.Web.Mvc.ViewPage
Ok – I made a little mistake. When I hit my ViewPage
pageBaseType=”System.Web.Mvc.ViewPage, System.Web.Mvc, Version=18.104.22.168, Culture=neutral, PublicKeyToken=31BF3856AD364E35″
userControlBaseType=”System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31BF3856AD364E35″>