.net httpHandlers 的配置与使用

13 篇文章 0 订阅

HttpHandler是asp.net真正处理Http请求的地方。在这个HttpHandler容器中,ASP.NET Framework才真正地对客户端请求的服务器页面做出编译和执行,并将处理过后的信息附加在HTTP请求信息流中再次返回到HttpModule中。


因为版本不同配置的节点位置有所不同

这是官方的配置节点

https://msdn.microsoft.com/zh-cn/library/7d6sws33(v=vs.80).aspx


在4.5版本的使用中发现

实际节点如下

<configuration>

  <system.webServer>
    <handlers>

<add name="prolist" verb="*" path="proinfo" type="mall.prolist,mall"/>

 </handlers>
   
  </system.webServer>

</configuration>

proinfo:是地址名称可以自定义配置

http://localhost:8361/prolist?pageindex=2&pagecount=1&queryparameters={%22proname%22:%22a%22}&Parametersign=360A9BA188A2B0E7217F018C4985E89B



一个简单的IHttpHandler

   

      第一:定义一个实现了IHttpHandler的类,并且实现其ProcessRequest方法。在一个HttpHandler容器中如果需要访问Session,必须实现IRequiresSessionState接口,这只是一个标记接口,没有任何方法。       

复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace MyHttpHandler
{
     public  class HelloHttpHandler:IHttpHandler
    {
         public  bool IsReusable 
        {
             get {  return  true; }
        }

         public  void ProcessRequest(HttpContext context) 
        {
            context.Response.Write( " HelloHttpHandler处理 ");
        }
    }
}

<add name="proinfo" verb="*" path="proinfo" type="MyHttpHandler. HelloHttpHandler,MyHttpHandler"/>
http://localhost:8361/proinfo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值