Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Getting handle on CurrentPage/PageBase from within PagePlugIn


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


Sep 30, 2013 15:46

You should be able to use the PageRouteHelper to get the CurrentPage:

var pageRouteHelper = ServiceLocator.Current.GetInstance<PageRouteHelper>();
PageData currentPage = pageRouteHelper.Page;


Sep 30, 2013 16:28

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....


Sep 30, 2013 16:44

Is this EPi 7 using MVC or WebForms?

Sep 30, 2013 16:50

Hi Chris,

It's using WebForms...


Sep 30, 2013 16:53

I'm trying to use this i MVC, and I also get null from using Chris's code.

Mar 06, 2014 15:02
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.