ASP.NET MVC 1.0 Areas
Areas (or grouping controllers into subsections of a site) are planned for ASP.NET MVC 2.0, but in the meantime there is a way to get this working with the current release.
Phil Haack’s nice area prototype hasn’t been updated since the release candidate of ASP.NET MVC, but it still works with version 1.0 by following his instructions.
But there is one catch that tripped me up - generic views don’t seem to work when they’re outside the ~/Views directory. For example, if you have a view in the ~/{Area}/Views folder with a page directive with a generic type in the Inherits attribute like this:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<list<person>>" %>
You get the error “Could not load type ‘System.Web.Mvc.ViewPage<list<person»’.
```
The way I got around this was to modify the configuration/system.web.pages element in my Web.config to set the pageParserFilterType to use the System.Web.Mvc.ViewTypeParserFilter, like this…
<pages pageparserfiltertype="System.Web.Mvc.ViewTypeParserFilter">
…and views in the non-root area that inherit ViewPage work fine.
From some of Phil Haack’s pages on views with code behind during the development of MVC 1.0, it looked like the MVC ViewTypeParserFilter was the default page parser filter for MVC applications, but it seems this filter is somehow selectively applied to the ~/Views folder. I’d be interested to find out how they do this, but it’s kind of academic at the moment since it’ll probably all be changed for version 2.0.
UPDATE: Thanks to the commenter who pointed out the way the MVC team did is was by setting the PageParserFilterType in the web.config inside the views folder.