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>");
                }
            }

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

  • 相关阅读:
    jwt
    mybatis的回顾
    swagger
    MySQl总结
    Java异常
    常用Dos命令
    C++初级项目——机房预约系统
    C++中将数字型字符串转变为int类型的方法
    C++中int *a; int &a; int & *a; int * &a
    #define_CRT_SECURE_NO_WARNINGS的用法
  • 原文地址:https://www.cnblogs.com/NeatFan/p/13158842.html
Copyright © 2011-2022 走看看