zoukankan      html  css  js  c++  java
  • .NetFrom验证方便的webconfig 配置及前台使用(推荐)

    总结一个比较简单的配置方式及前台使用方法

    在登陆页面Loing.aspx创建以后,把通过验证要跳转的地址提前创建好,后期会很方便。

    1.把Web.config进行简单基础的配置

     <authentication mode="Forms">
          <forms defaultUrl="TaskList.aspx" loginUrl="Loing.aspx">
            <credentials passwordFormat="Clear">
              <user name="admin" password="admin"/>
            </credentials>
          </forms>
        </authentication>
        <authorization>
          <allow users="admin"/>
          <deny users="?"/>
        </authorization>

    2.Loing.aspx前台配置

     protected void LoginButton_Click(object sender, EventArgs e)
            {
                if (FormsAuthentication.Authenticate(UserName.Text,Password.Text))
                {
                    FormsAuthentication.RedirectFromLoginPage(UserName.Text,true);
                }
                else
                {
                    Response.Write("<script>alert('非法进入!');location.href='Loing.aspx';</script>");
                }
            }

    很简单,两步走,但是有些单词可能比较长,要经常写和练才能记住。

  • 相关阅读:
    单(single)
    cdq分治
    寿司
    qtth
    二分,倍增的一些思考(lost my music:可持久化栈)
    手写堆、哈希表
    保留字,关键字
    测试19,20,21
    要买的书
    测试18:T2:可爱精灵宝贝
  • 原文地址:https://www.cnblogs.com/NeatFan/p/13158842.html
Copyright © 2011-2022 走看看