This is a migrated thread and some comments may be shown as answers.

Session Timeout Notification & Multiple Windows

6 Answers 871 Views
Notification
This is a migrated thread and some comments may be shown as answers.
J. E.
Top achievements
Rank 1
J. E. asked on 09 Aug 2011, 06:47 PM
Hi all,

I love the new notification control. I have been playing around with it and had a quick question. Right now, I have placed the control on the MasterPage for our application. While testing out the SessionTimeout example, I noticed that if I open a link in another tab or window, you run the risk of the notification appearing in multiple windows. Any one have any ideas how I can control the notification from appearing more than once or appearing pre-maturely in the original window?

Thanks,
JE

6 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 11 Aug 2011, 12:06 PM
Hello J. E.,

This is a really complex scenario which I am not sure is entirely possible. There are several approaches you can take and each has its drawbacks and limitations:

1) raise a flag in a Session[] variable when you open a content page. This flag can be used by the RadNotification to determine if the session has been prolonged by another page being requested. You can set this flag as the Notification's Value and check for it in the JavaScritpt. The exact way you will raise a flag and pass its value depends on your custom scenario - you coul use a hidden field as well. This will need the notification to perform a callback to update is content when it is about to show the redirect timer. Thus you can avoid the redirect, if necessary, but this will also prolong the user session if no other page has been opened. The redirect would still occur if your custom logic is correct, but the Session on the server will not be closed.

  2) find a way to access your pages via JavaScript, for example by storing references to the newly opened windows in global variables, then you can raise e flag in the old pages which will prevent the countdown of the notification even as you click the links from them. This would be possible if you only access other pages from within the first one opened, if you simply open a new tab and type in the address you could not access them

3) move the notification only to the desired content page to avoid duplicates.

Please note that there may be more ways to attack this and there maybe more issues that I have not foreseen in my suggestions. All this is a complex custom functionality that we do not support and it is the developer's responsibility to find a way to access his/her pages/controls.

All the best,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
J. E.
Top achievements
Rank 1
answered on 19 Aug 2011, 03:28 PM
Hi Marin,

Thank you for the response. I am still reviewing your suggestions, but I don't necessarily agree that this scenario is custom behavior. Users can choose to open a hyperlink in a separate window/tab by asking the browser to do so. We haven't coded this behavior, it is part of the browser and it is something that needs to be considered by the developers when using this new control.

As I said in my original post, we really do like the control, but we will need to consider how to use it, to prevent multiple notifications or pre-mature session timeouts.

Thanks again.
JE
0
Marin Bratanov
Telerik team
answered on 22 Aug 2011, 03:02 PM
Hi J. E.,

The RadNotification is simply a control that allows for the popup to become visible on the page as directed by the developer of the application. This means that if or when it should be shown is not decided by the control, but by the developer.

Determining when/if the session has ended or is renewed is nearly impossible via JavaScript, as this is a server-side object, and if you have a round-trip to the server to check it this will also renew it. This is the main difficulty in implementing such a notification, especially in a multipage scenario.

  Therefore if you are able to detect session start/end/near expiration via JavaScript then this is how and when you can show the notification, but we cannot provide it internally. This is also the reason why I call this a custom behavior.

While I am glad to hear that you like this new control I cannot say that all scenarios are possible with it, as the technology has some innate limitations. This is why I can recommend another approach - instead of redirecting you can make the tabs flash a message, so even if the warning comest early the user will, at leas,t not be redirected to a new page.


Greetings,
Marin
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Edward
Top achievements
Rank 1
answered on 08 Jun 2012, 05:26 PM
Hi Marin and J.E.

What about the use of AJax page.methods and APS.Net WebMethods.  There is someone else at http://stackoverflow.com/a/7029210/1161391 who is using these to poll the server every 30 seconds to see if the session has expired.  Do these callbacks keep the session alive?  (I seem to remember some issues with another timeout notification tool where they said that AJAX callbacks from within a update panel did not refresh the session.)
0
Marin Bratanov
Telerik team
answered on 12 Jun 2012, 09:57 AM
Hi Edward,

Such requests keep the session alive and you can confirm this in the SessionTimeout demo - it uses a callback (not even an AJAX request) to renew the session if you click the ContinueSession button. You can do this a few times and you will see the session is still active.


Kind regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Ian
Top achievements
Rank 1
answered on 07 Nov 2017, 05:10 PM

This is an old thread and it's now 5 years later. Has anyone come up with a good way of doing this?

Would it not be possible to do it using cookies assuming cookies are enabled? If another tab is open that tab/page resets the session refresh cookie. Other tabs can check for that cookie in JS and check it's expiry time, if it's still valid then don't show the RadNotification but reset it's timeout value.

Tags
Notification
Asked by
J. E.
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
J. E.
Top achievements
Rank 1
Edward
Top achievements
Rank 1
Ian
Top achievements
Rank 1
Share this question
or