.net实现IHttpModule接口顾虑器

这篇文章主要介绍了C#使用IHttpModule接口修改http输出的方法,涉及C#操作IHttpModule接口的相关技巧,非常具有实用价值,需要的朋友可以参考下
 

本文实例讲述了C#使用IHttpModule接口修改http输出的方法。分享给大家供大家参考。具体实现方法如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
//修改http输出先建个类这个类作为模块mould就要实现接口
namespace 修改_HTTP_输出
{
public class MyMould:IHttpModule
//实现接口
{
//点击实现接口就会出来以下对应的属性和一个方法
public void Dispose()
//处理属性
{
throw new NotImplementedException();
}
HttpContext c = null ;
//定义个下面要用的当前请求对象变量初值为null
public void Init(HttpApplication context)
//初始化方法,HttpApplication是应用程序类
{
this .c = context.Context;
//1:给当前请求c赋值,Context获取当前请求的Http特定信息
context.BeginRequest += new EventHandler(context_BeginRequest);
//当应用开始请求时;2:beginRequest是一个事件用委托定义事件
}
void context_BeginRequest( object sender, EventArgs e)
//事件的处理方法
{
c.Response.Write( "你的请求被我在mould中改了" );
}
//上面的事件响应需要注册测在web.config
}
}

转载于:https://www.cnblogs.com/jinhaoObject/p/4531198.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值