This topic is locked

Session Timeout Handling

6/20/2019 10:06:25 AM
ASPRunner.NET General questions
J
jetsguy author

Does anyone have any examples of best practices in ASPR.Net to handle session timeouts? I realize there may be several options such as redirecting on session timeout or giving users a warning and countdown before logging out.

I very much appreciate hearing from you if you can help me. Thank you.

jadachDevClub member 6/20/2019

I too would like to learn what others do in this regard. Too many times, my users keep an app open on their task bar and realize after performing some task, the app disconnected from the database due to time out. I am dealing with active directory.

J
jetsguy author 6/21/2019



I too would like to learn what others do in this regard. Too many times, my users keep an app open on their task bar and realize after performing some task, the app disconnected from the database due to time out. I am dealing with active directory.


I can't believe no one has done this before. So hopefully the community will respond.

jadachDevClub member 6/21/2019

I am looking at something like this for my purpose. Basically, to be on the safe side, if a page is up for 10 minutes, a javascript confirmation box will appear. Clicking OK will reload the page. So if the user is still connected no harm. If the user clicks cancel, it will go back to the menu page where it should force a new login if disconnected.

setTimeout(function() {

var timeout = confirm('Your session may have expired.');

if(timeout == true)

{

location.reload();

}

else

{

window.location = '/menu';

}

}, 600000);


The draw back to this approach is you need to add it to all add and edit pages javascript onload event.

Pete K 6/24/2019



I am looking at something like this for my purpose. Basically, to be on the safe side, if a page is up for 10 minutes, a javascript confirmation box will appear. Clicking OK will reload the page. So if the user is still connected no harm. If the user clicks cancel, it will go back to the menu page where it should force a new login if disconnected.

setTimeout(function() {

var timeout = confirm('Your session may have expired.');

if(timeout == true)

{

location.reload();

}

else

{

window.location = '/menu';

}

}, 600000);


The draw back to this approach is you need to add it to all add and edit pages javascript onload event.



That looks like a workable solution, Jerry. But the need to add the same code to many pages points out an inherent shortcoming of the ASPR platform. A couple of possible workarounds come to mind. You could add some server code to the AfterAppInit() event which would first test to see if this is an add or edit page and if so maybe use Response.Write to output the JS. Not sure of that would work but it might be worth a try.
Another thought: you could put the the JS code in the page header, in which case you would have to wrap it with some server code, similar to the above.

J
jetsguy author 6/24/2019

This looks like a good idea. Have you implemented anything like this that works?



That looks like a workable solution, Jerry. But the need to add the same code to many pages points out an inherent shortcoming of the ASPR platform. A couple of possible workarounds come to mind. You could add some server code to the AfterAppInit() event which would first test to see if this is an add or edit page and if so maybe use Response.Write to output the JS. Not sure of that would work but it might be worth a try.
Another thought: you could put the the JS code in the page header, in which case you would have to wrap it with some server code, similar to the above.

jadachDevClub member 6/24/2019



This looks like a good idea. Have you implemented anything like this that works?


I have. It works well for selected pages. No need for overkill and adding it everywhere. I have one app as an example that the users typically work off of a primary worklist (list page) that has connections to other tables, etc. The users like to minimize on their task bars and launch when they need to do work there. This approach helps that scenario.
One note. This only works if the edit or add pages are separate. basically, you need to leave the list page, then return. Otherwise you can't control the timer.