C#伪地址的应用

作者:互联网   出处:控件中国网   2014-11-05 19:05:15   阅读:1

C#伪地址的应用

建立httpModule

    <httpModules>
      <add type="WebSite.MyModule1" name="MyModule1"/>
    </httpModules>

  </system.web>


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

        void context_BeginRequest(object sender, EventArgs e)
        {
            HttpContext context = ((HttpApplication)sender).Context;
            string requestpath = context.Request.Path.ToLower();
            if (requestpath.IndexOf("news")>0)
            {
                context.RewritePath("../WebForm1.aspx");
            }
        }


 

Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat