ASP.NET HttpModules

   

ASP.NET provides several of its own HttpModules. These modules implement the different authentication types that ASP.NET uses. The Session object is also implemented as an HttpModule. Table 25.2 lists the HttpModules provided with ASP.NET.

Table 25.2. ASP.NET HttpModules

Module

Purpose

DefaultAuthenticationModule

Ensures that an Authenticationobject is present in the context.

FileAuthorizationModule

Verifies that the remote user has NT permissions to access the file requested .

FormsAuthenticationModule

Enables ASP.NET applications to use forms authentication.

PassportAuthenticationModule

Provides a wrapper around PassportAuthenticationservices.

SessionStateModule

Provides the functionality for the Sessionobject.

UrlAuthorizationModule

Provides URL-based authorization services for allowing or denying access to specified resources.

WindowsAuthenticationModule

Enables ASP.NET applications to use Windows/IIS authentication.

The basic usage of the security modules was discussed in Chapter 18, "Security," and the Session module in Chapter 4," Response, Application, and Session Objects "

Some of these modules expose events that can be handled in the Global.asax file. Here are the events that the different modules throw and how they must be handled in the Global.asax file:

  • DefaultAuthenticationModule This module exposes an event called Authenticate . The event handler should have the following Global.aspx format:

     //C#  DefaultAuthentication_OnAuthenticate(Object sender,      DefaultAuthenticationEventArgs e)  'VB  Sub DefaultAuthentication_OnAuthenticate(ByVal sender As Object,       ByVal e As DefaultAuthenticationEventArgs) 
  • FormsAuthenticationModule This module exposes an event called Authenticate . The event handler should have the following Global.aspx format:

     //C#  FormsAuthentication_OnAuthenticate(Object sender,      FormsAuthenticationEventArgs e)  'VB  Sub FormsAuthentication_OnAuthenticate (ByVal sender As Object,      ByVal e As FormsAuthenticationEventArgs) 
  • PassportAuthenticationModule This module exposes an event called Authenticate . The event handler should have the following Global.aspx format:

     //C#  PassportAuthentication_OnAuthenticate(Object sender,      PassportAuthenticationEventArgs e)  'VB  Sub PassportAuthentication_OnAuthenticate (ByVal sender As Object, ByVal e As    PassportAuthenticationEventArgs) 
  • SessionStateModule This module exposes two events called Start and End . The event handlers for these events should have the following Global.aspx format:

     //C#  Session_OnStart()  Session_OnEnd()  'VB  Sub Session_OnStart()  Sub Session_OnEnd() 
  • WindowsAuthenticationModule This module exposes an event called Authenticate . The event handler should have the following Global.aspx format:

     //C#  WindowsAuthentication_OnAuthenticate(Object sender,      WindowsAuthenticationEventArgs e)  'VB  Sub WindowsAuthentication_OnAuthenticate (ByVal sender As Object,     ByVal e As WindowsAuthenticationEventArgs) 

Be sure to note that if the event is handled in the Global.asax's code-behind file instead of in the Global.asax file, the handler name should not include On . For example, Session_OnStart() should be Session_Start .

   


Special Edition Using ASP. NET
Special Edition Using ASP.Net
ISBN: 0789725606
EAN: 2147483647
Year: 2002
Pages: 233

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net