DefaultHttpHandler Class
Assembly: System.Web (in system.web.dll)
A DefaultHttpHandler object intercepts incoming requests in the HTTP pipeline when both request interception has been configured through Microsoft Internet Information Services (IIS) version 6.0 and no explicit httpHandlers bindings apply to the requested extension.
Request interception can be set up through the wildcard application mapping feature introduced in IIS 6.0. For more information, search the MSDN Library for information about using wildcard application maps to remap a URL.
The DefaultHttpHandler class implements the IHttpAsyncHandler interface to provide asynchronous request processing. For general information about HTTP handlers, see Custom ASP.NET Processing with HTTP Handlers. Additionally, for more information:
-
About creating asynchronous HTTP handlers, see How to: Create an Asynchronous HTTP Handler.
-
About registering HTTP handlers, see How to: Register HTTP Handlers.
-
About developing and deploying asynchronous and synchronous HTTP handlers, see Extending ASP.NET Processing with HTTP Modules.
Classes can derive from the DefaultHttpHandler class to provide customized handling of requests. An asynchronous HTTP handler that is derived from the DefaultHttpHandler could override the BeginProcessRequest method to change how requests are processed.
A DefaultHttpHandler does not use ASP.NET errors. Existing content that uses IIS errors or a propriety ISAPI custom error mechanism would work unchanged.
The following code example demonstrates how to implement a customized HTTP handler by deriving from the DefaultHttpHandler class.
public class AsyncDefaultHttpHandler : DefaultHttpHandler { private HttpContext _context; public override IAsyncResult BeginProcessRequest( HttpContext context, AsyncCallback callback, object state) { AsyncResultSample ar = new AsyncResultSample(callback, state); _context = context; return ar; } public override void EndProcessRequest(IAsyncResult result) { _context.Response.Write("EndProcessRequest called."); } // This method should not be called asynchronously. public override void ProcessRequest(HttpContext context) { throw new InvalidOperationException( "Asynchronous processing failed."); } // Enables pooling when set to true public override bool IsReusable { get { return true; } } } // Tracks state between the begin and end calls. class AsyncResultSample : IAsyncResult { private AsyncCallback callback = null; private Object asyncState; private Boolean isCompleted; internal AsyncResultSample(AsyncCallback cb, Object state) { this.callback = cb; asyncState = state; isCompleted = false; } public object AsyncState { get { return asyncState; } } public bool CompletedSynchronously { get { return false; } } public WaitHandle AsyncWaitHandle { get { throw new InvalidOperationException( "ASP.NET should not use this property ."); } } public bool IsCompleted { get { return isCompleted; } } internal void SetCompleted() { isCompleted = true; if (callback != null) { callback(this); } } }
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.