MSDN中,有篇文章《在 ASP.NET 中使用 HTTPHandler 实现 Front Controller》,标题中的HTTPHandler指的是什么?

解决方案 »

  1.   

    http://www.frontfree.net/view/article_856.htmlhttp://www.itonline.gd.cn/ittech/list.asp?id=614
      

  2.   

    Methods in Http HandlerThe following are the methods in Http Handlers.
      Method Name Description 
    ProcessRequest Used o call Http Requests. 
    IsReusable To check the reusability of same instance handler with a new request of same type. Configuring HTTP Handlers 
    The <httpHandlers> configuration section handler is responsible for mapping incoming URLs to the IHttpHandler or IHttpHandlerFactory class. It can be declared at the computer, site, or application level. Subdirectories inherit these settings.Administrators use the <add> tag directive to configure the <httpHandlers> section. <Add> directives are interpreted and processed in a top-down sequential order. Use the following syntax for the <httpHandler> section handler:<httpHandlers>
    <add verb="[verb list]" path="[path/wildcard]" type="[COM+ Class], [Assembly]" validate="[true/false]" />
    <remove verb="[verb list]" path="[path/wildcard]" />
    <clear />
    </httpHandlers> Creating HTTP Handlers 
    To create an HTTP handler, you must implement the IHttpHandler interface. The IHttpHandler interface has one method and one property with the following signatures: 
    void ProcessRequest(HttpContext);
    bool IsReusable {get;}Customized Http HandlerBy customizing http handlers, new functionalities can be added to Web Server. Files with new extensions like .text for a text file can be handled by Web Server by using http handlers. The future of customization can lead to hosting .jsp pages in IIS by finding adequate ISAPI extensions. The following steps are involved to create customized http handler:
    1. Create a C# class library as 揈xamplehandler?br> 2. Name class as 揌andlerclass.cs?/font>using System;
    using System.Web;
    using System.Web.SessionState;
    namespace ExampleHandler
    {
    /// <summary>
    /// Summary description for Examplehandler.
    /// </summary>
    public class Handlerclass : IHttpHandler
    {
    public Handlerclass()
    {
    //
    // TODO: Add constructor logic here
    //
    }#region Implementation of IHttpHandler
    public void ProcessRequest(System.Web.HttpContext context)
    {
    HttpResponse objResponse = context.Response ;
    HttpSessionState objSession = context.Session ;
    objResponse.Write("<html><body><h1>Hello World from Handler") ;
    objResponse.Write("</body></html>") ;
    }public bool IsReusable
    {
    get
    {
    return true;
    }
    }
    #endregion
    }
    } Compile it and place it in the bin directory of TestApp project.
      

  3.   

    我知道了。
    HttpHandler :HttpHandler 是实现 IHttpHandler 或 IHttpAsyncHandler 接口的类;分为同步 HttpHandler和异步 HttpHandler。同步 HttpHandler 实现 System.Web.IHttpHandler 接口;异步 HttpHandler 实现 System.Web.IHttpAsyncHandler 接口。