Prior to 4.10 I had an event handler that dynamically swapped the masterpage of a page. This event was fired on UmbracoDefault.BeforeRequestInit and the sender object was converted to a System.Web.UI.Page, where the MasterPage property would be changed.
Now in 4.10 the same property is null. I understand that the request pipeline was rewritten for 4.10 and that this is not how the masterpage is set now, so I was wondering if anyone knows at what point Umbraco sets the masterpage for a node so that I can jump in and swap it.
The BeforeRequestInit event will be refactored in a near future, and a new way to programmatically change the masterpage will be introduced. In the meantime, you can't do it through BeforeRequestInit anymore, this is issue http://issues.umbraco.org/issue/U4-1149. But there is a workaround. You have to do:
void HandleAfterRequestInit(object sender, RequestInitEventArgs eventArgs) { int id = GetMyTemplateId(); var t = template.GetMasterPageName(id); Page.MasterPageFile = t; }
Setting the Masterpage via code in 4.10
Hi,
Prior to 4.10 I had an event handler that dynamically swapped the masterpage of a page. This event was fired on UmbracoDefault.BeforeRequestInit and the sender object was converted to a System.Web.UI.Page, where the MasterPage property would be changed.
Now in 4.10 the same property is null. I understand that the request pipeline was rewritten for 4.10 and that this is not how the masterpage is set now, so I was wondering if anyone knows at what point Umbraco sets the masterpage for a node so that I can jump in and swap it.
Thanks!
The BeforeRequestInit event will be refactored in a near future, and a new way to programmatically change the masterpage will be introduced. In the meantime, you can't do it through BeforeRequestInit anymore, this is issue http://issues.umbraco.org/issue/U4-1149. But there is a workaround. You have to do:
Stephan
Hi Stephan,
Thanks for your reply, I've got it all working again now! Thanks!
Braydie
is working on a reply...