Knowledge base for Cobisi's products and services
MVC areas is a cool feature introduced back with ASP.NET MVC version 2.0, which allows to easily structure models, views and controllers of ASP.NET MVC applications into their own subfolders, for an easier management. MVC Extensions develops this concept even further and allows to define routes by way of the Route attribute, giving the developer the freedom to structure models and controllers independently of their routes and, thus, the locations of their views.
Starting from version 1.3.5.709, however, MVC Extensions supports mixed configuration where declarative routes are applied to MVC actions which are contained in an MVC area as well. To take advantage of that, the declarative routing engine must be notified of any eventual MVC area it needs to support, before the related routes are registered. A single line of code is enough to achieve this behavior: an invocation to the RegisterArea() method of the DeclarativeRouteRegistration class, right from the target area registration code, as shown below for a fictitious "Baz" area:
public class BazAreaRegistration : AreaRegistration { public override string AreaName { get { return "Baz"; } } public override void RegisterArea(AreaRegistrationContext context) { DeclarativeRouteRegistration.RegisterArea(this, context, // Default namespace for the area, for locating views: "FooBar.Areas.Baz.Controllers"); // Not needed my the declarative routing engine, but you may want // to leave it here for something else. context.MapRoute(...); } }
Please don't hesitate to contact us if you have problems with any of our products or services; technical support is always free of charge, and requests made by registered clients will have higher priority.