WebConfig文件:
<authentication mode="Forms">
<forms name=".aspx" loginUrl="login.aspx" protection="All" timeout="60" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
在登陆界面的.cs文件中加入以下代码:
private void Login_Click(object sender, System.EventArgs e)
{

if((UserId.Text=="")&&(UserPass.Text ==""))
{
FormsAuthentication.RedirectFromLoginPage(UserId.Text ,PersistCookie.Checked);
}
else
{
Msg.Text ="验证失败,请重试";
}

}
就可以了,你试试看!!!