Click here to Skip to main content
12,622,291 members (35,078 online)
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads

Tagged as

Stats

3.6M views
11.3K downloads
730 bookmarked
Posted

ASP.NET Application and Page Life Cycle

, 8 Feb 2013 CPOL
ASP.NET application and page life cycle
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Collections;

/// <summary>
/// Summary description for clsLifeCycle
/// </summary>
public class clsHttpModule : IHttpModule
{
    private HttpApplication httpApp;
    public static ArrayList objArrayList = new ArrayList();
    public clsHttpModule()
	{
		//
		// TODO: Add constructor logic here
		//
        
	}


    public void Dispose()
    {
        //throw new Exception("The method or operation is not implemented.");
    }

    public void Init(HttpApplication context)
    {
       this.httpApp = context;
       httpApp.Context.Response.Clear();
       objArrayList.Clear();
       objArrayList.Add("httpModule:Init");
       httpApp.AuthenticateRequest += new EventHandler(OnAuthentication);
       httpApp.AuthorizeRequest += new EventHandler(OnAuthorization);
       httpApp.BeginRequest += new EventHandler(OnBeginrequest);
       httpApp.EndRequest += new EventHandler(OnEndRequest);
       httpApp.ResolveRequestCache += new EventHandler(OnResolveRequestCache);
       httpApp.AcquireRequestState += new EventHandler(OnAcquireRequestState);
       httpApp.PreRequestHandlerExecute += new EventHandler(OnPreRequestHandlerExecute);
       httpApp.PostRequestHandlerExecute += new EventHandler(OnPostRequestHandlerExecute);
       httpApp.ReleaseRequestState += new EventHandler(OnReleaseRequestState);
       httpApp.UpdateRequestCache += new EventHandler(OnUpdateRequestCache);        
    }
    void OnUpdateRequestCache(object sender, EventArgs a)
    {
        objArrayList.Add("httpModule:OnUpdateRequestCache");
    }
    void OnReleaseRequestState(object sender, EventArgs a)
    {
        objArrayList.Add("httpModule:OnReleaseRequestState");
    }
    void OnPostRequestHandlerExecute(object sender, EventArgs a)
    {
        objArrayList.Add("httpModule:OnPostRequestHandlerExecute");
    }
    void OnPreRequestHandlerExecute(object sender, EventArgs a)
    {
        objArrayList.Add("httpModule:OnPreRequestHandlerExecute");
    }
    void OnAcquireRequestState(object sender, EventArgs a)
    {
        objArrayList.Add("httpModule:OnAcquireRequestState");
    }
    void OnResolveRequestCache(object sender, EventArgs a)
    {
        objArrayList.Add("httpModule:OnResolveRequestCache");
    }
    void OnAuthorization(object sender, EventArgs a)
    {
        objArrayList.Add("httpModule:OnAuthorization");
    }
    void OnAuthentication(object sender, EventArgs a)
    {
       
        objArrayList.Add("httpModule:AuthenticateRequest");
    }
    void OnBeginrequest(object sender, EventArgs a)
    {
        
        objArrayList.Add("httpModule:BeginRequest");
    }
    void OnEndRequest(object sender, EventArgs a)
    {
        objArrayList.Add("httpModule:EndRequest");
        objArrayList.Add("<hr>");
        foreach (string str in objArrayList)
        {
            httpApp.Context.Response.Write(str + "<br>") ;
        }
        
    }
    
}
public class clsHttpHandler : IHttpHandler
{

    public bool IsReusable
    {
        get { return true; }
    }

    public void ProcessRequest(HttpContext context)
    {
       clsHttpModule.objArrayList.Add("HttpHandler:ProcessRequest");
       context.Response.Redirect("Default.aspx");
    }
}

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)

Share

About the Author


You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161128.1 | Last Updated 9 Feb 2013
Article Copyright 2010 by Shivprasad koirala
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid