Master Pages and EPiServer CurrentPage property

Posted on May 20, 2009 by Frederik Vig in Code Snippet, EPiServer

When you use user controls or web forms in your EPiServer web application you usually inherit from either UserControlBase or TemplatePage. Which gives you, among other things, the CurrentPage property. The problem is when you need the CurrentPage property in your Master Page.

The way I usually fix this is with this code.

var page = (PageBase) Page;

This should work fine in both EPiServer 4 and 5.

Related Posts: