Wednesday, February 17, 2010

ASP.NET MVC2 RC2 - Breaking Area Registration Change

With the release of ASP.NET MVC RC2 there is a breaking change in the way area registration works. As of RC2, all AreaRegistration types must be marked public, or they will be ignored by calls to AreaRegistration.RegisterAllAreas(). To me this seems rather arbitrary in nature, but I suspect the reasoning for the change stems from the fact that with the initial preview of MVC2 areas had to be implemented as separate projects. Thus, if the access modifier on the AreaRegistration type for a given Area project is not public, it would not be picked up by the call to RegisterAllAreas() in the main web project without violating access modifier constraints (private member reflection). So to reiterate, if you were originally doing something like this:
internal class AdminArea : AreaRegistration {}
You must change the access modifier to public in order for the area to be registered and added to the routes table.

No comments: