3

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.

Community
  • 1
  • 1
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
  • @AlexeiLevenkov did you _read_ my question at all ? I don't see in the duplicated question any mention for _when_ page is crated. Please notice . – Royi Namir Sep 29 '12 at 08:57
  • I think second one give you the [link](http://msdn.microsoft.com/en-us/library/bb470252.aspx) which says it happens during MapRequestHandler on step 10: "The handler can be a native-code module such as the IIS 7.0 StaticFileModule or a managed-code module such as the PageHandlerFactory " – Alexei Levenkov Sep 29 '12 at 18:19

1 Answers1

2

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.

Jupaol
  • 21,107
  • 8
  • 68
  • 100
  • yeah you right http://books.google.co.il/books?id=2wg5LCKuChcC&pg=PA189&lpg=PA189&dq=%22for+a+web+form+request,+this+is+the+point+when+the+page+is+compiled%22&source=bl&ots=HjwehFyeIJ&sig=A9Myhuxp7ioo4q2MRAkhCRNFiHM&hl=en&sa=X&ei=ALZmUKenEq_S4QTIo4G4Dw&redir_esc=y#v=onepage&q=%22for%20a%20web%20form%20request%2C%20this%20is%20the%20point%20when%20the%20page%20is%20compiled%22&f=false. I had to find it in my book. why doesn't msdn state it ? – Royi Namir Sep 29 '12 at 08:50
  • I remember I read it somewhere in the extensive MSDN documentation, cannot find it though... – Jupaol Sep 29 '12 at 08:54