MyDevBank

MyDevBank

summaries and tech views for new developers C#,asp.net for web\mobile development,databases,iis6 and more.
Creating this site was an idea that popped up after some programing years, when you have to get back to the same things you all ready forgot, while new stuff is arriving to town. In this site you can find summaries on tech stuff im into, so for a stable wide base knowledge pyramid ,enjoy!!

Http Modules

after the creation of the HttpContext object the HttpApplication object is created and while it does HttpModules get is action.
HttpModules stand for code that was writen for events the HttpApplication fires.

While the Application object is suitable for handling application-wide events and data on a small scale, sometimes application-wide tasks need a little heavier machinery. HttpModules serve that purpose.

ASP.NET includes a number of predefined HttpModules. For example, session state, authentication, and authorization are handled via HttpModules. Writing HttpModules is pretty straightforward, and is a great way to handle complex application-wide operations. For example, if you wanted to write your own authentication scheme, using HttpModules is a good way to do it.

These events are listed below in the order in which they are executed:
  1. BeginRequest
  2. AuthenticateRequest event
  3. internal event
  4. AuthorizeRequest event
  5. ResolveRequestCache event
  6. Internal step to "map handler" (when compilation takes place, a page instance is created)
  7. AcquireRequestState event
  8. PreRequestHandlerExecute event
  9. Internal step to "execute handler" (when the page code is executed)
  10. PostRequestHandlerExecute event
  11. ReleaseRequestState event
  12. Internal step to filter responsesUpdateRequestCache event
  13. UpdateRequestCache event
  14. EndRequest event
The following items can handle these events:
  • Internal ASP.NET page framework (for example, steps 6, 9, and 12 in the preceding list).
  • HTTP modules that are configured for the application. The default list of HTTP modules is defined in the Machine.config file. Additional custom modules may be specified by the developer in the web.config for the application.
  • Code in Global.asax that is hooked through the Application_[On]EventName method or that is hooked explicitly when you add event handlers for an alternative handler name.
Code:
public class MyHttpModules:IHttpModule
{
...
    public void Init(HttpApplication context)
    {
    context.BeginRequest += new EventHandler(context_BeginRequest);
    context.ResolveRequestCache += new EventHandler(context_ResolveRequestCache);
    context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
    !!!between this two events the relevant handler will create the page and send the content to the buffer
    context.PostRequestHandlerExecute += new EventHandler(context_PostRequestHandlerExecute);

add to web.config

<httpmodules>
   <add name="MyModule" type="MyHttpModules"/> <- MyHttpModules = the class name
</httpmodules>

Comment | Related Tags

HOME| IIS6 pipeline| ASP.NET pipeline| Http Modules| Http Handlers| Caching| Web Services| Page Life Cycle| Ajax| Jquery| Session State
ViewState| SEO| Mobile Basics| Mobile Handsets| C# Modifiers| C# Keywords| N-Tier| Design patterns| Stack & Heap| WCF
Databases| Relational Model| functionalities| Stored procedures| fishmarket
MyDevBank
© 2010 All Rights Reserved