Search code examples
asp.net-mvcareas

How to implement Areas in ASP.NET MVC 1.0 to be most compatible with ASP.NET MVC 2.0


Until the preview release yesterday of ASP.NET MVC I had been desperately needing a feature like 'areas' but not known what it was called to be able to find it.

The preview release describes 'areas' as :

Areas - provide a means of dividing a large web application into multiple projects, each of which can be developed in relative isolation. This helps developers manage the complexity of building a large application by providing a way to group related controllers and views.

In my case I am building an online store as one part of the application. I'd like to partition everything under /store/ with controllers like /store/products/ and /store/checkout.

The ASP.NET 2.0 areas feature seems to be exactly what I want, but I cant yet justify moving to it for a production application (although its very tempting!).

I noticed that Phil had an article about 'grouping controllers' way back in November - actually titled 'Areas in ASP.NET MVC'

Would really be interested if anybody has used either approach - or prefarably someone familiar with both.

I'd like to move my store logic into a separate 'area' as soon as possible - but can't decide whether to try to use Phil's November solution or just risk implementing it with the preview release? I assume that even some of my code would need to change - the RESTful URLS I would have created would not need to change so I'm leaning towards trying the 'grouping controllers' method for now. Anybody tried either?

http://haacked.com/archive/2008/11/04/areas-in-aspnetmvc.aspx

MSDN areas documentation: http://msdn.microsoft.com/en-us/library/ee307987(VS.100).aspx


Solution

  • I'm using Phil's earlier areas prototype (the one you linked to) in MVC 1.0 in the project I'm currently working on. It seems to work similar to MVC 2.0 areas, and it's working fine so far for me. There is a tweak you need to make to get generic views working though.

    Like you, I can't justify using the preview release for production code... hopefully it won't be too much work to refactor later when 2.0 is released.