开发者

LoginView and custom Authenticate ASP.NET WF

I have LoginView in MasterPage, when isn't user logged, application show LoginControl.ascx. In this LoginControl.ascx I make authenticate. Problem is, that, when application authenticate user, then LoginView not change from anonymous template to authenticate template.

protected void btnLogin_clicked(object sender, EventArgs e)
{
    // check username and password
    if (PlatneJmeno(txtUsernane.Text) && PlatneHeslo(txtPassword.Text))
    {
        if (Membership.ValidateUser(txtUsernane.Text, txtPassword.Text))
        {
            //For开发者_开发技巧msAuthentication.RedirectFromLoginPage(txtUsernane.Text, false);
            Response.Redirect(Request.RawUrl);
        }
        else
        {
            Session["LoginError"] = true;
            Session["LoginFromPage"] = Request.RawUrl;
            Response.Redirect("login.aspx");
        }
    }
    else
    {
        Session["LoginError"] = true;
        Session["LoginFromPage"] = Request.RawUrl;
        Response.Redirect("login.aspx");
    }
}

ok, done...

FormsAuthentication.SetAuthCookie(txtUsernane.Text, false);


It appears the problem you are running into is caused by the call to FormsAuthentication.RedirectFromLoginPage being commented out.

That call drops the cookie that tells ASP.NET that the user has been authenticated. Without the cookie ASP.NET will treat future requests as unauthenticated and continue to show the login page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜