Hi, the code below work fine when in a .net 1.1 app pool, but as soon as I put it in a .net2 app pool it fails to redirect to the default home page even though the user is authenticated
public static bool AuthenticateUser(string userId, string password, bool persistCookie) { bool flag = false; if (BoostApplication.ValidateUser(userId, password)) { DateTime now = DateTime.Now; DateTime expiration = now; if (persistCookie) { expiration = expiration.AddYears(1); } FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userId, now, expiration, persistCookie, userId); string str = FormsAuthentication.Encrypt(ticket); HttpContext.Current.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, str)); //HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str); if (persistCookie) { //cookie.Expires = expiration; } //HttpContext.Current.Response.Cookies.Add(cookie); BoostApplication.SetUserAndLanguage(userId, BoostApplication.CurrentLanguage); if (AuthenticationTicket(HttpContext.Current) != null) { flag = true; } } return flag; }
void btnLogin_Click(Object sender, EventArgs e) { if (Campus.CampusApplication.AuthenticateUser(txtUserId.Text, txtPassword.Text)) { Response.Redirect("~/home.aspx", false); } else { pnlError.Visible = true; Response.Write("h"); } }
The commented out lines are the what are used when running in a .net 1.1 app pool, so I would uncomment them when running in a .net 1.1 app pool.
Thanks