Click here to Skip to main content
15,896,154 members
Articles / Web Development / ASP.NET

Introducing ASP.NET Page Modules

Rate me:
Please Sign up or sign in to vote.
3.81/5 (10 votes)
15 Apr 2010CPOL3 min read 57.5K   360   48  
This article introduces the concept of Page Modules, which are similar to HTTP Modules but related to Page Life Cycle, and the need for them.
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;

namespace PauloMorgado.Web.UI
{
    /// <summary>
    /// Provides data for the <see cref="E:PageHandlerFactoryWithModules.PageCreated"></see> event.
    /// </summary>
    public class PageCreatedEventArgs : PageEventArgs
    {
        private HttpContext context;
        private string requestType;
        private string virtualPath;
        private string path;

        /// <summary>
        /// Initializes a new instance of the <see cref="T:PauloMorgado.Web.UI.PageHandlerFactoryWithModules.UI.PageCreatedEventArgs"/> class.
        /// </summary>
        /// <param name="page">The <see cref="T:Page"/> that processes the request.</param>
        /// <param name="context">An instance of the <see cref="T:System.Web.HttpContext"/> class that provides references to intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        /// <param name="requestType">The HTTP data transfer method (GET or POST) that the client uses.</param>
        /// <param name="virtualPath">The virtual path to the requested page.</param>
        /// <param name="path">The <see cref="P:System.Web.HttpRequest.PhysicalApplicationPath"/> property to the requested page.</param>
        public PageCreatedEventArgs(Page page, HttpContext context, string requestType, string virtualPath, string path)
            : base(page)
        {
            this.context = context;
            this.requestType = requestType;
            this.virtualPath = virtualPath;
            this.path = path;
        }

        /// <summary>
        /// Gets the <see cref="T:System.Web.HttpContext"/> of the HTTP requests.
        /// </summary>
        /// <value>The <see cref="T:System.Web.HttpContext"/> of the HTTP requests.</value>
        public HttpContext Context
        {
            get { return this.context; }
        }

        /// <summary>
        /// Gets the HTTP data transfer method (GET or POST) that the client uses.
        /// </summary>
        /// <value>The HTTP data transfer method (GET or POST) that the client uses.</value>
        public string RequestType
        {
            get { return this.requestType; }
        }

        /// <summary>
        /// Gets the virtual path to the requested page.
        /// </summary>
        /// <value>The virtual path to the requested page.</value>
        public string VirtualPath
        {
            get { return this.virtualPath; }
        }

        /// <summary>
        /// Gets the  <see cref="P:System.Web.HttpRequest.PhysicalApplicationPath"/> property to the requested page.
        /// </summary>
        /// <value>The  <see cref="P:System.Web.HttpRequest.PhysicalApplicationPath"/> property to the requested page.</value>
        public string Path
        {
            get { return this.path; }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Paulo Morgado
Portugal Portugal

Comments and Discussions