zoukankan      html  css  js  c++  java
  • 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
     

  • 相关阅读:
    luffy后台登录+注册+课程
    luffy前台登录+注册+课程
    luffy前台准备
    luffy后台准备
    跨域请求
    pip源和虚拟环境的搭建
    Book接口
    drf-Xadmin的使用
    drf-JWT认证
    drf-自动生成接口文档
  • 原文地址:https://www.cnblogs.com/xyangs/p/2381237.html
Copyright © 2011-2022 走看看