Get current System.Web.UI.Page from HttpContext?

No, from MSDN on HttpContext.Current: “Gets or sets the HttpContext object for the current HTTP request.”

In other words it is an HttpContext object, not a Page.

You can get to the Page object via HttpContext using:

Page page = HttpContext.Current.Handler as Page;

if (page != null)
{
     // Use page instance.
}

Leave a Comment