Search code examples
c#asp.nethttpmodule

HttpModule and Page creation?


Possible Duplicate:
HTTPModule Event Execution Order?

I'm investigating where does the Page object is initially created in the HttpModule Pipeline :

 HttpModule 

     ===========
    #1  BeginRequest
    #2  AuthenticateRequest
    #3  AuthorizeRequest
    #4  RespolveRequestCache
    #5  AcquireRequestState 
    #6  PreRequestHandnlerExecute

    Handler
    ========
    #7  ProcessRequest

   ... later stages
   ================

and here is my expirament :

I've register each function to execute a specific method :

  void check(object sender, EventArgs e)
        {
          Page objPage = (sender as HttpApplication).Context.Handler as Page;
          if (objPage == null) return;
          ...
        }

the first stage where the "safe cast" worked successfully was the AcquireRequestState .

Question :

It did worked for me , but is it a safe place to acquire the page class ?

Also , why isn't it documented anywhere ? I've searched in Msdn in what stage the page class is first accessible , and couldn't find any.


Solution

  • It's created between the PostResolveRequestCache and AcquireRequestState

    From the top of my head, I think that PostAcquireRequestState would be safer to access the page

    Occurs when the request state (for example, session state) that is associated with the current request has been obtained.