AI OnAI Off
You should be able to use the PageRouteHelper to get the CurrentPage:
var pageRouteHelper = ServiceLocator.Current.GetInstance<PageRouteHelper>();
PageData currentPage = pageRouteHelper.Page;
Hi Chris,
Thanks for your response. Unfortunately this too returns null - both the PageLink and Page proeprties of pageRouteHelper are null.
Really scratching my head on this one....
Al
I'm trying to use this i MVC, and I also get null from using Chris's code.
Hi all,
I've developed a PagePlugin so that we can carry out some HTMLRewriting of hyperlinks - we are modifying the markup EPiServer spits out if the hyperlink is to a binary asset such as a PDF/DOC/DOCX.
This works fine, however the requirements have changed slightly and now we need to be able to turn this functionality on/off on a page by page basis. As we have developed a PagePlugin I thought we should be able to implement the ICustomPluginLoader and then cast the current handler to PageBase, and then check for a property on the page i.e. check whether the HTMLRewriting property (true/false) has been disabled. However, within the List() member of the ICustomPluginLoader HttpContext.Current.Handler always returns null, just as it does within the Initialize method of the PagePlugin.
Does anyone have any thoughts on how I can get access to the Current Page, or even the current handler (so it can be cast to a PageBase object) from within the PagePlugin?
Thanks in advance
Al