0
我无法将用户从登录页面发送到需要身份验证的页面。用户在第一页上进行身份验证,但在第二页上进行身份验证后,会立即发送到登录页面。下面的代码的要点....Net Forms身份验证身份验证不会出现
页需要再次验证:
protected void Page_Load(object sender, EventArgs e)
{
/*Make sure the user is authenticated. If not, redirect them to the Login page*/
if (!HttpContext.Current.Request.IsAuthenticated)
else
LabelMsg.Text = "User: " + System.Web.HttpContext.Current.Request.LogonUserIdentity.Name.ToString();
} //end Page_Load()
这里的登录密码的要点:
if (GridViewBookList.Rows.Count > 0)
{
string[] roles = new string[] { "admin", "newbooks" };
HttpContext.Current.User = new GenericPrincipal(new GenericIdentity(TextBoxUser.Text), roles);
FormsAuthentication.SetAuthCookie("admin", true);
FormsAuthentication.RedirectFromLoginPage(TextBoxUser.Text, true);
}
else
{
LabelMsg.Text = "Incorrect username or password";
如果任何人都可以是任何援助,它将不胜感激。
我已经放弃Membership.ValidateUser(),而是创建了自己的认证码。我是离开基地吗? – librariman
我试着用我自己的代码替换Membership.ValidateUser(),这是一个不行。 – librariman