Reputation: 23
I have a hosted Silverlight 4 application. My task is to notify a Silverlight user when his ASP.NET session is about to expire with a simple dialog box, saying something like "Your session is about to expire, would you like to reset the session?" with two buttons [Yes], and [No]. When the user clicks [Yes] I would like to update the ASP.NET session, otherwise I would just let it expire. What is the best methodology to use here?
I've taken a look at different forums, and most people just simply poll the server every-so-often from the page hosting the Silverlight application. This wouldn't do for me. I thought of creating a singleton DispatcherTimer that would start on Silverlight application startup, would fetch Session.Timeout value from the server using WCF and would run for (Session.Timeout - some delta) minutes. When the timer expires it would pop the notification window. Moreover, since this notification window should only pop after a period of inactivity, I'd like to reset this timer every time a WCF call is performed (which essentially defines activity). Is this sound? Are there any better methods? What are your thoughts?
P.S. I'm also planning on doing something similar for Forms timeout.
Upvotes: 1
Views: 1628
Reputation: 78890
You may or may not be opposed to this, but I've found it useful in RIAs to have a timer running that makes a keep-alive request to the ASP.NET server in order to prevent the session from expiring while the application is active. At the same time, in case something happened on the server that caused the session to expire, you could detect that condition in the keepalive handling and tell the client that the expiration has taken place.
Upvotes: 0