zoukankan      html  css  js  c++  java
  • 简单的过滤器

    1  新建个类库 添加 system.web的应用

    2 实现 IHttpModule的接口

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web;

    namespace FirstModule

    {
    class FirstModule :System.Web.IHttpModule
    {

    //为请求管道的第一个事件 ,也是就BeginRequest  的事件注册一个用户自动以的一个方法

    public void Init(HttpApplication app)
    {
    app.BeginRequest += Fun; 

    }
    public void Fun(object sender, EventArgs e)
    {
    HttpApplication app = sender as HttpApplication;
    app.Context.Response.Write("每个页面前都会出现这句话");

    }


    public void Dispose()
    {
    throw new NotImplementedException();
    }
    }
    }

    3  在配置文件中有2种方式配置

    1 在sysrem web内配置 对应iiss  集成模式

    <httpModules>
    <add name="first" type="FirstModule.FirstModule"/>
    </httpModules>

    2 在sysyetm web外配置 对应经典模式

    <!--<system.webServer>

    <modules>

    <add name="first" type="FirstModule.FirstModule"/>

    </modules>

    </system.webServer>-->

    ----------------------在全局配置文件中实现过滤器问题

    // 利用事件自动机制俄日当前网站的 Application里的事件注册方法
    ////命名规则 一定要以 Application_ 作为开头
    //protected void Application_BeginRequest(object sender, EventArgs e)
    //{
    // System.Web.HttpApplication app= sender as HttpApplication;
    // app.Context.Response.Write("全局事件里配置过滤器");

    //}

  • 相关阅读:
    execvp
    Linux系统调用getrlimit()与setrlimit()函数详解
    Va_start及Vsprintf应用
    waitpid()
    sdut 2408 Pick apples 夜
    poj 1273 Drainage Ditches 夜
    poj 1408 Fishnet 夜
    poj 1113 Wall 夜
    poj 1584 A Round Peg in a Ground Hole 夜
    poj 3007 Organize Your Train part II 夜
  • 原文地址:https://www.cnblogs.com/cdaq/p/3579504.html
Copyright © 2011-2022 走看看