• HttpModule Url 重写


    1.新建MyModule去实现IHttpModule接口

        //当前请求的应用程序的对象的变量
    private HttpApplication _application;

    //初始化事件
    public void Init(HttpApplication context)
    {
    _application = context;
    //加载context执行的事件context_BeginRequest
    context.BeginRequest+=new EventHandler(context_BeginRequest);
    }
    void context_BeginRequest(object sender, EventArgs e)
    {
    //在此对请求的Url重写

    //要定义到的路径
    string path = "admin/index.aspx";

    //获取被请求的路径
    string requstPath = _application.Context.Request.RawUrl;

    string[] list = requstPath.Split(Convert.ToChar("/"));
    if(list[list.Length-1]=="index.aspx")
    {
    _application.Context.RewritePath(path);
    }

    }

    2.配置文件,定义全局应用该MyModeule

            <httpModules>
    <add name="MyModule" type="MyModule,App_Code"/>
    </httpModules>

    主要用于隐藏URL地址或者是伪装URL
     

  • 相关阅读:
    Codeforces Round #564(div2)
    714
    1471
    UVa 11134
    UVa 1152 -4 Values whose Sum is 0—[哈希表实现]
    UVa 1374
    UVA 1343
    UVa 12325
    Yet Another Number Sequence——[矩阵快速幂]
    River Hopscotch-[二分查找、贪心]
  • 原文地址:https://www.cnblogs.com/xyangs/p/2381237.html
Copyright © 2020-2023  润新知