IHttpModule相对来说,是一个网页的添加
IHttpHandler相对来说,却是网页的替换
先建一个HandlerDemo的类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Http_Handler_Model
{
public class HandlerDemo : IHttpHandler
{
/*
这个IsReusable的true是可以提高效率但是,会线程不安全
IHttpHandler实例可以再次使用
false,会安全一些,效率会低一些
IHttpHandler的实例就不能使用
*/
public bool IsReusable => true;
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
context.Response.Write("<h2>这是HandlerDemo做出来的</h2>");
}
}
}
在建一个Module的类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web