文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>ASP.NET 登录验证

ASP.NET 登录验证

时间:2010-12-27  来源:pinky

Web.Config:

    <system.web>
        <authorization>
            <deny users="?"/>
        </authorization>

      <authentication mode="Forms">
              <forms loginUrl="Login.aspx" timeout="2880" defaultUrl="Default.aspx" />

          </authentication>

       </system.web>

Login.aspx.cs

  

protected void btnLogin_Click(object sender, EventArgs e)
        {

            string userName = txtUserName.Text;
            string userPwd = txtUserPwd.Text;

            UserInfo userObj = userOper.CheckLogin(userName, userPwd);
            if (userObj == null)
                Response.Write("<script>alert('用户名或密码错误!');</script>");
            else
            {
                Session["UserInfo"] = userObj;
               
                FormsAuthentication.SetAuthCookie(userObj.UserName, false);
                Response.Cookies.Add(new HttpCookie("UserName", userObj.UserName));
                Response.Redirect(FormsAuthentication.DefaultUrl);
            }
        }

 

相关阅读 更多 +
排行榜 更多 +
秘境寻宝2手游下载

秘境寻宝2手游下载

角色扮演 下载
食用手册app官方版下载

食用手册app官方版下载

生活实用 下载
战国代手机版下载

战国代手机版下载

棋牌卡牌 下载