您的位置:首页 > 编程语言 > ASP

ASP.NET登录身份验证 一

2007-11-13 22:09 357 查看
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");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: