O'Reilly logo

Professional ASP.NET 3.5 Security, Membership, and Role Management with C# and VB by Stefan Schackow, Bilal Haidar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.4. Using the DefaultHttpHandler

The DefaultHttpHandler is a public class with a number of virtual methods that you can override. As a first step towards integrating ASP.NET authentication and authorization with classic ASP, you can create a custom HttpHandler that derives from DefaultHttpHandler:

C#

public class CustomHandler : DefaultHttpHandler
{
    public CustomHandler() {}

    public override string OverrideExecuteUrlPath()
    {
        //gets called just before control is handed back to IIS 6
        return null;
    }
public override void EndProcessRequest(IAsyncResult result)
 {
     //gets called when the original ISAPI extension is done processing
     //This step is useful for post-processing
     base.EndProcessRequest(result);
 }
}

VB.NET

Public Class CustomHandler
   Inherits DefaultHttpHandler

   Public Sub New()
   End Sub

   Public Overrides Function OverrideExecuteUrlPath() As String
         'gets called just before control is handed back to IIS 7.0
         Return Nothing
   End Function

   Public Overrides Sub EndProcessRequest(ByVal result As IAsyncResult)
         'gets called when the original ISAPI extension is done processing
         'This step is useful for post-processing
         MyBase.EndProcessRequest(result)
   End Sub
End Class

This code represents the basic skeleton of a custom HttpHandler. It overrides the two core methods available on DefaultHttpHandler: OverrideExecuteUrlPath and EndProcessRequest. You want to override the method OverrideExecuteUrlPath rather than the virtual BeginProcessRequest method for the following reasons:

  • Although you could ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required