码迷,mamicode.com
首页 > Web开发 > 详细

.net httpHandlers 的配置与使用

时间:2015-04-22 13:56:36      阅读:149      评论:0      收藏: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

.net httpHandlers 的配置与使用

标签:

原文地址:http://blog.csdn.net/wangzhiqiang123456/article/details/45193463

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!