Sitecore 8.1. Developer's Notes
I took a two months long hiatus from writing to transition into my new role at work. It’s all good now and I am back with an overdue post about Sitecore 8.1
Routes and the MVC Areas
Sitecore 8.1 has finally added native support for MVC areas. If you’ve used areas before (using this option, for example) you probably were calling AreaRegistration.RegisterAllAreas()
during <initialize>
and registering your routes in RegisterArea()
:
1 | using System.Web.Mvc; |
You can now take your own area registration out. Or can you? Here’s how Sitecore changed the InitializeRoutes
:
1 | protected virtual void RegisterRoutes(RouteCollection routes, PipelineArgs args) |
The problem is - area registration is called after route handlers have been set. I briefly mentioned the custom route handlers in my older blog post about Sitecore MVC routing mechanisms. This is what makes otherwise regular MVC routes Sitecore aware. No custom handlers on your routes means no mvc.*
pipelines, no PageContext
, no analytics.
All the routes that you were registering in
RegisterArea()
are now not part of the Sitecore MVC ceremonies. They are late to the party.