Firecroft
Firecroft

Reputation: 11

asp.net c# - Generic handler (ashx) and BasePage

In my C# asp.net project I have a BasePage (in \App_Code), and ordinary aspx pages inherit the BasePage. The challenge is to access the BasePage when there is no direct inheritance.

To get access to the BasePage from my MasterPage I do the following:

private BasePage MyBasePage
{
    get
    {
        try
        {
            return (BasePage)Page;
        }
        catch
        {
            return new BasePage();
        }
    }
}

Thus I can access the BasePage by MyBasePage.myVoid()

From a UserControl it's as simple as (this.Page as BasePage).myVoid().

But in a generic handler (ashx), that inherits the IHttpHandler, how can I get access to the BasePage?

Upvotes: 1

Views: 389

Answers (0)

Related Questions