自定义IHttphandler接口

  1. 首先实现IHttphandler接口
     1using System;
     2using System.Data;
     3using System.Configuration;
     4using System.Web;
     5using System.Web.Security;
     6using System.Web.UI;
     7using System.Web.UI.WebControls;
     8using System.Web.UI.WebControls.WebParts;
     9using System.Web.UI.HtmlControls;
    10
    11
    12namespace TestHttp
    13{
    14
    15    public class TestHandler : IHttpHandler
    16    {
    17
    18        public void ProcessRequest(HttpContext context)
    19        {
    20            context.Response.Write("Hello World!");
    21        }

    22
    23        public bool IsReusable
    24        {
    25            get
    26            {
    27                return true;
    28            }

    29        }

    30    }

    31}

  2. 接下来配置Web.config,添加<httpHandlers>节点
    1<httpHandlers>
    2            <add verb="*" path="Default.aspx" type="TestHttp.TestHandler, IHttphandler"/>
    3        </httpHandlers>
posted @ 2007-09-06 17:29  许晓光  阅读(217)  评论(2编辑  收藏  举报