C#过滤器HttpModule的使用,如下代码示例:
- using System;
- using System.Web;
- public class HttpModule:IHttpModule
- {
- public void Dispose()
- {
- }
- public void Init(HttpApplication application)
- {
- application.BeginRequest+=new EventHandler(Application_BeginRequest);
- application.EndRequest+=new EventHandler(Application_EndRequest);
- }
- void Application_BeginRequest(Object source,EventArgs e)
- {
- HttpApplication application=(HttpApplication)source;
- HttpContext context=application.Context;
- context.Response.Write("自定义模块");
- }
- void Application_EndRequest(Object source,EventArgs e)
- {
- HttpApplication application=(HttpApplication)source;
- HttpContext context=application.Context;
- context.Response.Write("自定义模块");
- }
- }
- /*
- * 在配置文件中配置
- *<system.web>
- *<httpModule>
- *<add name="HttpModule" type="HttpModule"/>
- *</httpModule>
- *</system.web>
- */
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索application
, context
, public
, source
, HttpApplication
void
c站、c语言、cf、ch、c罗,以便于您获取更多的相关知识。
时间: 2024-11-02 15:14:45