zoukankan      html  css  js  c++  java
  • 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="类型的完全限定名称,所在程序集的名称"

  • 相关阅读:
    2. Redis哨兵、复制、集群的设计原理与区别
    1. 详解Redis的存储类型、集群架构、以及应用场景
    博客园主题优化
    【Java基础】Java面试题精选
    【Java集合】——集合类分析总结
    新零售供应链的三大闭环
    Comparable和Comparator比较实现排序 场景分析
    Java基础-枚举类
    Java基础-泛型
    微服务架构~BFF和网关
  • 原文地址:https://www.cnblogs.com/ninghongkun/p/6368993.html
Copyright © 2011-2022 走看看