/// <summary> /// The page is initialised. /// </summary> /// <param name="pageContext">The page content.</param> public abstract void OnInit(HttpPageContext pageContext);
/// <summary> /// The page is loading. /// </summary> /// <param name="pageContext">The page content.</param> public abstract void OnLoad(HttpPageContext pageContext);
/// <summary> /// The pre-process event. /// </summary> /// <param name="pageContext">The page content.</param> public abstract void OnPreProcess(HttpPageContext pageContext);
/// <summary> /// The page hierachy initialiser. /// </summary> /// <param name="page">The current page instance.</param> /// <param name="urlFilePath">The local file name and full path of the resource.</param> /// <param name="context">Provides access to the request and response objects.</param> public static void PageInitialiser(HttpPageBase page, string urlFilePath, IHttpContext context) { // Make sure that the page exists. if (page != null) { System.IO.Stream outputResponse = null; System.IO.Stream inputRequest = null; try { // Create a new page context. HttpPageContext pageContext = new HttpPageContext(); pageContext.IsValid = true; pageContext.OverrideRequestResponse = false; pageContext.ProcessOnPostBack = true; // Assign the initial values. page.Request = context.HttpContext.Request; page.Response = context.HttpContext.Response; page.IsPostBack = context.ActiveProcess.IsPostBack; page.UrlFilePath = urlFilePath; page.User = context.HttpContext.User; // Execute the page hierachy. page.OnInit(pageContext); // If true then continue if (pageContext.IsValid) { // Assign the current active processing. page.ActiveProcessing = context.ActiveProcess; // Execute the pre-processing event. page.OnPreProcess(pageContext); if (pageContext.ProcessOnPostBack) { // If post back. if (context.ActiveProcess.IsPostBack) { // Get all the post back data. context.ActiveProcess.ProcessPostBack(page.Request, page.UploadDirectory); page.Form = context.ActiveProcess.Form; page.UploadFiles = context.ActiveProcess.UploadFiles; } } // Execute the page load event. page.OnLoad(pageContext); if (!pageContext.OverrideRequestResponse) { // If alternative content is to be sent. if (page.AlternativeContent != null) { // Get the request, response stream. outputResponse = context.HttpContext.Response.OutputStream; // Transfer the data to the client. inputRequest = HttpResponseContent.CreateResponseStream(page.AlternativeContent); HttpResponseContent.TransferResponse(inputRequest, outputResponse); } else { // Get the request, response stream. outputResponse = context.HttpContext.Response.OutputStream; // Get the response html. Create the response. Transfer the data. byte[] responseResourceHtmlData = HttpResponseContent.ResourceFound(context.HttpContext.Response, context.ActiveProcess, urlFilePath, System.IO.Path.GetExtension(urlFilePath).TrimStart('.')); // Transfer the data to the client. inputRequest = HttpResponseContent.CreateResponseStream(responseResourceHtmlData); HttpResponseContent.TransferResponse(inputRequest, outputResponse); } } } } catch (Exception) { throw; } finally { try { if (inputRequest != null) { inputRequest.Close(); } } catch (Exception ex) { page.Exception = ex; } try { if (outputResponse != null) { outputResponse.Close(); } } catch (Exception ex) { page.Exception = ex; } } } }