我通常将表单身份验证用于登录表单
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
if(FormsAuthentication.Authenticate(Login1.UserName, Login1.Password))
{
FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);
}
}
和web.config
有
<authentication mode="Forms">
<forms defaultUrl="Page.aspx">
<credentials passwordFormat="Clear">
<user name="Enter here" password="Enter here" />
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
但是,这不适用于 .NET 4.5。有什么更好的方法?