I searched, but I did not find the answer to this question. How can I get the value on the server, how much time is left before the session expires? My session settings:
// wait time, for example, 10 minutes
<authentication mode="Forms"> <forms name=".ASPXAUTH_External" loginUrl="Authentication/Unauthorized.aspx" protection="All" timeout="10" path="/" slidingExpiration="true" defaultUrl="~/Pages/home.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false"/>
</authentication>
<sessionState mode="InProc" timeout="10">
</sessionState>
I get the initial value (it will get 10 * 60 = 600 seconds):
SessionStateSection sessionSection = (SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState");
countdown.Text = sessionSection.Timeout.TotalSeconds.ToString();
But when the session time is less than half, and the user does some action. I get the initial value of 600, but it is not equal for the left session, because "slideExpiration" add some time (I do not know how much), but does not reset the session time on the left to the beginning of 10 minutes point.
How can I get the remaining session time before expiration?
source
share