zoukankan      html  css  js  c++  java
  • 浅谈Httpmodules

    HttpModule是ASP.NET过滤器,可以理解为HTTP请求的必经之地
    我们只要实现IHttpModule接口,就可以取代HttpModule

    namespace BookShop.Handler
    {
    public class TestModule : IHttpModule
    {
    /// <summary>
    /// 您将需要在网站的 Web.config 文件中配置此模块
    /// 并向 IIS 注册它,然后才能使用它。有关详细信息,
    /// 请参见下面的链接: http://go.microsoft.com/?linkid=8101007
    /// </summary>
    #region IHttpModule Members

    public void Dispose()
    {
    //此处放置清除代码。
    }

    public void Init(HttpApplication context)
    {
    // 下面是如何处理 LogRequest 事件并为其
    // 提供自定义日志记录实现的示例
    context.LogRequest += new EventHandler(OnLogRequest);
    context.BeginRequest += Context_BeginRequest;
    context.EndRequest += Context_EndRequest;
    }

    private void Context_EndRequest(object sender, EventArgs e)
    {
    HttpApplication app = sender as HttpApplication;
    app.Context.Response.Write("执行了HttpMoudle的endRequest事件");
    }

    private void Context_BeginRequest(object sender, EventArgs e)
    {
    HttpApplication app = sender as HttpApplication;
    app.Context.Response.Write("执行了HttpMoudle的BeginRequest事件");

    }

    #endregion

    public void OnLogRequest(Object source, EventArgs e)
    {
    HttpApplication app = source as HttpApplication;
    app.Context.Response.Write("执行了HttpMoudle的LogRequest事件");
    }
    }
    }


    web.config
    <httpModules>
    <add name="myHttpModule" type="ClassLibrary1.MyHttpModule,ClassLibrary1"/>
    </httpModules>

  • 相关阅读:
    STM32F401
    按字母顺序排列的IDC函数列表
    IDA 中文字符串
    Retrieving ST-Link/V2 Firmware from Update Utility
    IDA IDC Tutorials: Additional Auto-Commenting
    IDA resources
    Digital Current-Mode Control Challenges Analog Counterparts
    SQLSERVER 里SELECT COUNT(1) 和SELECT COUNT(*)哪个性能好?
    将ACCESS数据库迁移到SQLSERVER数据库
    RedGate 工具SQLMultiScript1.1
  • 原文地址:https://www.cnblogs.com/ZaraNet/p/9433533.html
Copyright © 2011-2022 走看看