zoukankan      html  css  js  c++  java
  • ASP.NET登录身份验证 一

    reference:
    http://blog.csdn.net/haojialin/archive/2006/01/13/578869.aspx

    新建一个vs2005 web项目,修改web.config下面的authentication / authorization 节点

        <authentication mode="Forms">
          
    <forms loginUrl="Login.aspx" name=".ASPXAUTH"></forms>
        
    </authentication>
        
    <authorization>
          
    <deny users="?"></deny>
        
    </authorization>

    新建2个页面:
    Login.aspx
    页面添加2个textbox,1个button,后台添加buttonclick事件:
        protected void Button1_Click(object sender, EventArgs e)
        {
            
    if (this.Txt_UserName.Text == "Admin" && this.Txt_Password.Text == "123456")
            {
                System.Web.Security.FormsAuthentication.RedirectFromLoginPage(
    this.Txt_UserName.Text, false);
            }
        }

    Default.aspx
    在页面添加一个button,后台添加一个事件:
        protected void Button1_Click(object sender, EventArgs e)
        {
            System.Web.Security.FormsAuthentication.SignOut();
            Server.Transfer(
    "Login.aspx");
        }
  • 相关阅读:
    python 小爬虫
    动态规划,网易秋招
    leetcode 3
    leetcode 27 水
    leetcode 21 list merge
    leetcode 15 3sum & leetcode 18 4sum
    leetcode 389 map iterator 的使用
    [转]使用flask实现mock server
    python __str__repr__ 区别
    Robot Framework 源码阅读 day2 TestSuitBuilder
  • 原文地址:https://www.cnblogs.com/zc22/p/958492.html
Copyright © 2011-2022 走看看