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