C#使用IHttpModule接口修改http輸出的方法
更新時間:2015年05月04日 11:24:18 作者:songguo
這篇文章主要介紹了C#使用IHttpModule接口修改http輸出的方法,涉及C#操作IHttpModule接口的相關(guān)技巧,非常具有實用價值,需要的朋友可以參考下
本文實例講述了C#使用IHttpModule接口修改http輸出的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
//修改http輸出先建個類這個類作為模塊mould就要實現(xiàn)接口
namespace 修改_HTTP_輸出
{
public class MyMould:IHttpModule
//實現(xiàn)接口
{
//點擊實現(xiàn)接口就會出來以下對應的屬性和一個方法
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
}
}
希望本文所述對大家的C#程序設(shè)計有所幫助。
您可能感興趣的文章:
- c#使用Socket發(fā)送HTTP/HTTPS請求的實現(xiàn)代碼
- C#使用HttpPost請求調(diào)用WebService的方法
- C#使用Http Post方式傳遞Json數(shù)據(jù)字符串調(diào)用Web Service
- C#請求http向網(wǎng)頁發(fā)送接收數(shù)據(jù)的方法
- C#根據(jù)http和ftp圖片地址獲取對應圖片
- C#模擬http 發(fā)送post或get請求的簡單實例
- C#如何解析http報文
- C#基于socket模擬http請求的方法
- C#實現(xiàn)發(fā)送簡單HTTP請求的方法
- C#實現(xiàn)簡單的Http請求實例
- 實例詳解C#實現(xiàn)http不同方法的請求
相關(guān)文章
Asp.Net(C#)使用oleDbConnection 連接Excel的方法
ADO.NET采用不同的Connection對象連接數(shù)據(jù)庫。這篇文章主要介紹了Asp.Net(C#)使用oleDbConnection 連接Excel的方法,非常具有實用價值,需要的朋友可以參考下2018-11-11
C#/.Net 中快速批量給SQLite數(shù)據(jù)庫插入測試數(shù)據(jù)
這篇文章主要介紹了C#/.Net 中快速批量給SQLite數(shù)據(jù)庫插入測試數(shù)據(jù),本文直接給出實例代碼,需要的朋友可以參考下2015-06-06
DevExpress實現(xiàn)GridControl刪除所有行的方法
這篇文章主要介紹了DevExpress實現(xiàn)GridControl刪除所有行的方法,對于C#初學者有一定的參考借鑒價值,需要的朋友可以參考下2014-08-08

