Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

user logged out frequently (Default Membership provider)

I have asp.net mvc 3 site deployed on shared hosting. My problem is that my site frequently logged out user automatically after 5 to 10 min. Although i have set the time to 200 min in web.config and application_start as shown below

<forms loginUrl="~/Account.mvc/index" slidingExpiration="true" timeout="200" protection="All" />



HttpCookie authCookie = FormsAuthentication.GetAuthCookie(userName, rememberMe);
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);   
FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddMinutes(200), rememberMe, CurrentUser.UserID +"|"+ CurrentUser.EmployeeID);     
authCookie.Value = FormsAuthentication.Encrypt(newTicket);
Response.Cookies.Add(authCookie);
like image 949
Tassadaque Avatar asked Oct 10 '22 14:10

Tassadaque


1 Answers

Hopefully, this will help:

  • <machineKey decryptionKey="AutoGenerate"... being ignored by IIS. Won't invalidate previous session's cookies
  • http://msdn.microsoft.com/en-us/library/ff649308.aspx
like image 79
Alex Yakunin Avatar answered Oct 25 '22 12:10

Alex Yakunin