Search code examples
asp.nethttphandlerhttpmodule

Interaction between httpmodules and httphandlers


In our asp.net 2.0 app we are using httpmodule and httphandler to calculate some metrics via cookies. To calculate network transfer time, httpmodule:EndRequest stores Transferstart in the cookie and httphandler:Processrequest uses datetime.now to subtract the transferstart to determine overall network time. Is this correct? I am also unclear about the request flow process. Does it go something like this: request > HttpModule::OnStart > HttpModule::OnEnd > HttpHandler::ProcessRequest?


Solution

  • The order is:

    • Module OnStart
    • Handler ProcessRequest
    • Module OnEnd

    By the way, it's probably better to use HttpContext.Items property to share info between a handler and a module instead of a cookie.