I am using ASP.NET identity membership. This is the Startup.Auth.cs code:
app.CreatePerOwinContext(EFDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
// Configure the sign in cookie
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
ExpireTimeSpan = TimeSpan.FromHours(3),
CookieName = "MyLoginCookie",
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, User>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
As you can see I've set expiretimespan
to 3 hours, but on the production server it doesn't work; it expires in about ten minutes. When I inspect elements MyLoginCookie still exists. On localhost it works fine. Why does it have problems on the production server? Do I need to set CookieDomain?
Go to Advanced power settings (click on Windows button, write power options, click on Power Options, in the selected plan click on the Change plan settings, click on the Change advanced power settings). 9. Click Sleep, then System unattended sleep timeout, then change these settings from 2 Minutes to 20 for example.
Press Windows icon key on the keyboard, type Settings and select the top most search result. Select Personalization and click on Lock screen from the left side panel of the window. Click on Screen timeout settings and set the time limit or select Never from the drop down bar under Screen option.
Log off using “Ctrl” + “Alt” + “Delete” You can also find the sign out option in the menu accessed by pressing "Ctrl" + "Alt" + "Delete" on your keyboard. 2.
You might get signed out of everything if your cache data gets corrupted. Clearing cache data to remove the junk and broken cookies to fix the sign-out problem.
The reason for users logging off is because of error in validation of forms-authentication data and view-state data. It could happen for different reasons including using web farm in hosting services.You should check <machineKey>
in your project webconfig
. Check here for details about that. If you don't have<machineKey>
in your webconfig
, try adding this piece of code after <system.web>
in your webconfig:
<machineKey
validationKey="AutoGenerate,IsolateApps"
decryptionKey="AutoGenerate,IsolateApps"
validation="HMACSHA256"
decryption="Auto"
/>
The other option is using generated ASP.NET Machine Key inside webconfig. There are some online tools which my recommended ones are this and this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With