When I added a new Area in my DXA application, Visual Studio scaffolded out a RegisterArea method in the AreaRegistration... which adds a route mapping for the area.
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Foo_default",
"foo/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
I'm not sure how to deal with this. On the one hand, it's handier to have all the routing together in the global asax. On the other hand, I can see benefits in keeping area-specific code in the area.
I'm therefore leaning towards keeping it where it is, but first I'd like to be clear that there are no good reasons not to. Would I need to modify this code in order to have it work well with DXA?
Edit: My class inherits from BaseAreaRegistration, as indicated by the documentation. Unfortunately, the documentation doesn't really cover this issue. Presumably, even if VS hadn't scaffolded the routing, I'd still need to consider whether I need custom routing for my area, and if so where best to put it.
If you examine the route mappings in the Global.asax, they all reference the Core area specifically, like this:
.DataTokens.Add("area","Core")
It's not clear to me what this does, or whether it's relevant.
I suppose the point is that the DXA page controller takes over complete responsibility for the whole URL, rather than having the route parse out controller/action/id by default. The route is still called "Core_Page": is it reasonable to assume that the name doesn't have any functional effect?