zoukankan      html  css  js  c++  java
  • 重写URL后指定特定页面

    今天学到一点小技术:   

         1.利用"实现类或者相对应的模块"加载时进行初始化判断URL的定向!

              a.先建立一个继成IHttpModule接口的类,在Init方法中初始化或者处理事件

                   // 初始化

                    public void Init(HttpApplication context)
                      {
                          context.BeginRequest += new EventHandler(context_BeginRequest);
                      }

                    //处理事件

                    private void context_BeginRequest(object sender, EventArgs e)
                   {
                     HttpContext context = ((HttpApplication)sender).Context;
                     RewritePost(context);
                   }

     

                 //重写URL  

                 private static void RewritePost(HttpContext context)
                 {

                     context.RewritePath("/testHttpModules/post.aspx?id=22", false);

                 }


              b.在配置文件中加入HtppModule模块,以便起动程序时就开始运行IHttpModule中的方法,来处理所需!

              

  • 相关阅读:
    JVisualVM简介与内存泄漏实战分析
    高并发性能提升和超卖的解决方案
    ehcache应用场景及集群同步(RMI)
    一台机器配置多个tomcat的实践经验
    事务范围数据库读写分离失败
    基于spring的数据库读写分离
    Zookeeper linux下使用
    Zookeeper集群
    Dubbo入门实例(二)
    Zookeeper安装与启动
  • 原文地址:https://www.cnblogs.com/lbg280/p/1353358.html
Copyright © 2011-2022 走看看