IsAuthenticated is false!

Posted by Naor on Stack Overflow See other posts from Stack Overflow or by Naor
Published on 2011-01-16T03:34:12Z Indexed on 2011/01/16 3:53 UTC
Read the original article Hit count: 238

This is how I login ('user' holds the data of the user):

HttpResponse Response = HttpContext.Current.Response;
        HttpRequest Request = HttpContext.Current.Request;
        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
            user.UserId.ToString(), DateTime.Now, DateTime.Now.AddHours(12), false,
            UserResolver.Serialize(user));

        HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
            FormsAuthentication.Encrypt(ticket));
        cookie.Path = FormsAuthentication.FormsCookiePath;

        Response.Cookies.Add(cookie);

        string redirectUrl = user.HomePage;
        Response.Redirect(redirectUrl);

After this login I get IsAuthenticated == false. Why??

It worked for me before an hour but I don't know what is wrong now.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about authentication