Detecting Session Timeout in Silverlight
The SL3 DataGrid has a download XLS column to download the details of the record in Excel format. On click of the Download button, first the user is prompted with a SaveFileDialog to select the file and then a WCF call is made to开发者_运维问答 fetch the details of the selected record. Using 3rd party excel helper library, the records are added to an excel sheet and the file is saved.
The problem is that when the Session has timed out (say, due to idleness), the click functions perfectly well, prompting the user to specify the file to save, and then a redirect is made to the login page (as expected, since we are handling the not authenticated errors etc).
However, the user is now in an illusion that an empty Excel file has been downloaded.
So, is there a way to detect from Silverlight page, if the Session has timed out? And thereby showing the SaveFileDialog only when the Session is available.
You can probably send the heartbeat from Silverlight to ASP.NET. This is very common issues in Ajax world as well. As you can use Javascript in Silverlight as well, you may want to check this solution Keeping ASP.NET Session Open / Alive
If you dont like to JS then you can either use HttpWebRequest or WebClient to communicate with asp.net ...
精彩评论