zoukankan      html  css  js  c++  java
  • url 重定向的原理

    1----------------------------在全局配置文件中写url重写

    //命名规则 一定要以 Application_ 作为开头 url 重写
    protected void Application_BeginRequest(object sender, EventArgs e)
    {
    System.Web.HttpApplication app = sender as HttpApplication;
    fackProcess(app);

    }
    void fackProcess(HttpApplication app)
    {

    //
    HttpContext context = app.Context;
    //获取当前的静态url /Student/Detaiel/1
    string statcinrul = context.Request.RawUrl;
    //解析url
    string[] strpath = statcinrul.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

    //判断url
    if (strpath[0] == "student") // /student
    {

    if (strpath[1] == "list") // /student/list
    {

    }
    else if (strpath[1]=="details")// student/details
    {
    // dtudent/details/1
    if (strpath.Length == 3 && !string.IsNullOrEmpty(strpath[2]))
    {

    //符合 重写url
    context.RewritePath("/2.aspx?id=" + strpath[2]);
    }

    }

    }


    }

    2-------------------------------------------------

  • 相关阅读:
    杂记-2
    2019CSP-S游记
    csp2020
    特征根法小记
    csp模拟赛低级错误及反思
    备份
    黑科技——树剖两次dfs转一次dfs!
    输出天干地支
    蓝桥0531-输出Y
    蓝桥0615-判断四位数字前后两组是否相等
  • 原文地址:https://www.cnblogs.com/cdaq/p/3581376.html
Copyright © 2011-2022 走看看