Session Timeout Warn & redirect to login page

Hi All,

I'm expecting a solution in the asp.net to warn the user before the session expires due to the inactivity and still the session is inactive then it should redirect to login page. Please help me in implementing the solution.
SessionExpired-MessageWindow.PNG
learntechnologyAsked:
Who is Participating?
 
learntechnologyConnect With a Mentor Author Commented:
Thanks everyone. Since Forms Time out & Session Timeout values are different. I tried using following lines of code. Below code redirects to the session expired page if the screen is inactive for 1 minute.

<meta http-equiv="refresh" content="0060; URL=/Account/SessionExpired.aspx" />
0
 
rajapandian_81Commented:
Hi,

You can use "setTimeout" function in javascript. You can set time in milliseconds. After that time the message will be prompted.
setTimeout(function() { if (confirm("Your session expired due to inactivity. Please click [OK] to login again.")) { window.location.href = "login.aspx" } }, 1200000);

Open in new window

0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Alan WarrenApplications DeveloperCommented:
Session.Timeout and Forms.Authentication.Timeout are two different animals, for these things to work as intended, both need to be in synch.
    ' Get the current Forms.Authentication.Timeout as a timespan
    ' The amount of time in minutes after which the authentication expires. 
    Dim currentFormsTimeout As System.TimeSpan = FormsAuthentication.Timeout

    ' Synch session timeout and forms timeout
    Session.Timeout = currentFormsTimeout.TotalMinutes

Open in new window

Then you can use something like this Preventing Session Timeouts in C# ASP .NET to extend the timeout period.

Alan
0
 
learntechnologyAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for learntechnology's comment #a38407592

for the following reason:

Since other solutions are not feasible to the requirement. I have implemented the following code after thorough analysis and testing.<br /><br />&lt;meta http-equiv=&quot;refresh&quot; content=&quot;0060; URL=/Account/SessionExpire<wbr />d.aspx&quot; /&gt;
0
 
learntechnologyAuthor Commented:
Since my solution is feasible after testing, i'm comfortable to close this request. If anyone has better solution than this with simple code, i would be happy to accept that solution.
0
 
learntechnologyAuthor Commented:
Below code redirects to the session expired page if the screen is inactive for 1 minute.

<meta http-equiv="refresh" content="0060; URL=/Account/SessionExpired.aspx" />

Above code works good after testing.
0
 
learntechnologyAuthor Commented:
Since my solution is feasible after testing, i'm comfortable to close this request. If anyone has better solution than this with simple code, i would be happy to accept that solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.