Base solution for your next web application
Open Closed

SQL Server Session mode #3354


User avatar
0
moustafa created

I'm using SQL Server Session mode in my web application that depends on aspnetboilerplate templates only (asp.net zero not involved) i set timeout to 720 minutes but unfortunately it still expires after 20 minutes i created database for creating sessions web.config

<system.web>
	<sessionState allowCustomSqlDatabase="true" cookieName="myCookies" mode="SQLServer" sqlCommandTimeout="180" sqlConnectionString="Data Source=ServerName;Initial Catalog=mcsorgsa_sessionstate;User ID=DatabaseName; Password=xxxxxxx;" timeout="720" cookieless="false" />
  </system.web>

Startup.cs

public void Configuration(IAppBuilder app)
        {
            app.UseAbp();

            app.UseOAuthBearerAuthentication(AccountController.OAuthBearerOptions);

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                ExpireTimeSpan = TimeSpan.FromMinutes(720),
                SlidingExpiration = true,
                Provider = new CookieAuthenticationProvider
                {
                    OnResponseSignIn = signInContext =>
                    {
                        signInContext.Properties.IssuedUtc = DateTime.UtcNow;
                        signInContext.Properties.ExpiresUtc = DateTime.UtcNow.Add(TimeSpan.FromMinutes(720));
                    }
                }
            });

            app.MapSignalR();
        }

after cookiea are been expired when trying to access web api service i got this error Empty or invalid anti forgery header token then when i refresh the page i detect i'm not be signed on anymore , and i'm very sure the session stored in database not expired yet what's is going on ? any ideas? regards,


2 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    This might be solution for your case <a class="postlink" href="https://stackoverflow.com/questions/37086645/how-to-set-asp-net-identity-cookies-expires-time">https://stackoverflow.com/questions/370 ... pires-time</a>.

    Thanks.

  • User Avatar
    0
    moustafa created

    Hi I'll try thank you