Extend custom System.Web.UI.Page implementer to include custom property than can be accessed by page and master page
<p>I have created a class called BasePage which inherits System.Web.UI.Page. On this page I've declared a property called UserSession which I want to be able to access from any Page/MasterPage. </p>

<pre><code>public class BasePage : System.Web.UI.Page
{
    string UserSession { get; set; }

    public BasePage()
    {
        base.PreInit += new EventHandler(BasePage_PreInit);
    }

    private void BasePage_PreInit(object sender, EventArgs e)
    {
        UserSession = "12345";
    }
}
</code></pre>

<p>My Default.aspx.cs page inherits the BasePage class and allows me to access the UserSession property as expected.</p>

<pre><code>public partial class Default : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(UserSession);
    }
}
</code></pre>

<p>However, even though Default.aspx has MasterPage.Master assigned correctly, when I try and access the UserSession property from MasterPage.Master.cs it can't find it and won't build.</p>

<p>So what am I trying to achieve by doing this? I want to expose a UserSession object to every page in my application. Pretty simple you would have thought? Nope.</p>
