Hello. Faced such a problem: It is necessary to extend the user session to the maximum possible. Here is the code of the class itself with the help of which I am authorizing the user:
public static class AuthenticationExtensions { public const string StringValueType = "http://www.w3.org/2001/XMLSchema#string"; public static void SignIn(this Controller controllerBase, CustomerUserSM user, bool isPersistent = false) { var authenticationManager = controllerBase.HttpContext.GetOwinContext().Authentication; authenticationManager.SignIn(); authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); var identity = new ClaimsIdentity(DefaultAuthenticationTypes.ApplicationCookie, ClaimTypes.Name, ClaimTypes.Role); identity.AddClaim(new Claim(ClaimTypes.Name, user.FullName, StringValueType)); identity.AddClaim(new Claim(ClaimTypes.Email, user.Email, StringValueType)); identity.AddClaim(new Claim(ClaimTypes.Role, user.Role, StringValueType)); identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.PKID.ToString())); authenticationManager.SignIn(new AuthenticationProperties { IsPersistent = isPersistent }, identity); } public static void SignOut(this Controller controllerBase) { var authenticationManager = controllerBase.HttpContext.GetOwinContext().Authentication; authenticationManager.SignOut(); } } I tried to specify in Web.config:
<authentication mode="Forms"> <forms timeout="99999999"/> </authentication> <sessionState timeout="525500" /> However, this did not help.