zoukankan      html  css  js  c++  java
  • web.config配置不同的跳转页面

    1、admins目录访问时转到admins/login.aspx
    2、other.aspx访问时转到login.aspx
    
    配置文件设置拒绝other.aspx和admins目录,默认登录页面为login.aspx,并设置允许匿名访问admins/login.aspx
    
    <configuration>
    <system.web>
        <authentication mode="Forms">
          <forms loginUrl="login.aspx"> </forms>
        </authentication>
    </system.web>
    
      <location  path="other.aspx">
        <system.web>
          <authorization>
            <deny users="?"/>
          </authorization>
        </system.web>
      </location>
      <location  path="admins/login.aspx">
        <system.web>
          <authorization>
            <allow users="?"/>
          </authorization>
        </system.web>
      </location>
      <location  path="admins">
        <system.web>
          <authorization>
            <deny users="?"/>
          </authorization>
        </system.web>
      </location>
    </configuration>
    
    

    在login.aspx页面Page_Load事件里加判断:

     

                string url = Request.QueryString["ReturnUrl"];
                if (!string.IsNullOrEmpty(url) && url.StartsWith("/admins/"))
                {
                    Response.Redirect("admins/login.aspx");
                }
    

  • 相关阅读:
    单词统计
    团队项目介绍--“益青春APP”
    团队项目 NABCD介绍
    兰猪耳
    薄雪万年草
    佛甲草
    针叶天蓝绣球
    白芨
    萱草
    吉祥草
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/1942762.html
Copyright © 2011-2022 走看看