• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
灬伊天?
博客园    首页    新随笔    联系   管理    订阅  订阅

030-IHttpModule

MyHttpModule.cs

 1     public class MyHttpModule : IHttpModule
 2     {
 3         public void Dispose()
 4         {
 5 
 6         }
 7 
 8         public void Init(HttpApplication context)
 9         {
10             //为HttpApplication对象注册管道事件
11             context.BeginRequest += context_BeginRequest;
12         }
13 
14         void context_BeginRequest(object sender, EventArgs e)
15         {
16             HttpContext.Current.Response.Write("dlb");
17         }
18     }

引用➹

Index.aspx

 1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="t5_Main.Index" %>
 2 
 3 <!DOCTYPE html>
 4 
 5 <html xmlns="http://www.w3.org/1999/xhtml">
 6 <head runat="server">
 7     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 8     <title></title>
 9 </head>
10 <body>
11     <form id="form1" runat="server">
12         <div>
13             yg
14         </div>
15     </form>
16 </body>
17 </html>

Web.config

 1 <?xml version="1.0" encoding="utf-8"?>
 2 
 3 <!--
 4   有关如何配置 ASP.NET 应用程序的详细信息,请访问
 5   http://go.microsoft.com/fwlink/?LinkId=169433
 6   -->
 7 
 8 <configuration>
 9   <system.web>
10     <compilation debug="true" targetFramework="4.5" />
11     <httpRuntime targetFramework="4.5" />
12   </system.web>
13   <system.webServer>
14     <modules>
15       <add name="MyHttpModule" type="t5_HttpModule.MyHttpModule,t5_HttpModule"/>
16     </modules>
17   </system.webServer>
18 </configuration>

<httpModules>
  <add name="myModule" type="Aspx.CRUD.UI.MyHttpModule,Aspx.CRUD.UI"/>
</httpModules>
type="Aspx.CRUD.UI.MyHttpModule,Aspx.CRUD.UI"
表示➹
type="类型的完全限定名称,所在程序集的名称"

posted @ 2017-02-06 01:21  灬伊天☂  阅读(168)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3