Silverlight, RIA, and ASP.Net Session Timeout

We have a requirement when we would like to redirect the user to the login page, when the ASP.NET session expires and the user is working in the Silverlight plugin.

So, the scenario: we have an outdated application that runs ASP.Net, all of our new modules are in Silverlight, and the outdated application loads the Silverlight application. It all works :-) Then the user leaves his desktop and returns after the ASP.Net session, but then tries to continue to do something in the Silverlight application that uses the RIA domain service. Since the session has a timeout, the RIA domain service fails, but it does not break with a SessionExpired exception or with an invalid username / password, it just fails with a domain exception that is similar to the "real" exceptions specified in the domain so that we have There is no way to determine that this time it happened because the session has expired.

There are many answers to the question of how to keep an ASP.Net session in life, we do not want to do this, we want the session to end, but we want to be able to process it gracefully in Silverlight and direct the user to the login page.

We have this work, but the problem is that whenever an exception occurs in a Silverlight application, it redirects you to the login page, which is not the intended behavior. We just want to redirect when this session expires.

Any ideas?

+5
source share
1 answer

I had the same problem. I added the following code to Application_UnhandledException:

private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
    // redirect to login on exceptions when user is not logged in
    var domainException = e.ExceptionObject as DomainOperationException;
    if (domainException != null && !WebContext.Current.User.IsAuthenticated) 
    { // probably a server-side timeout has occurred.  
        e.Handled = true;
        HtmlPage.Document.Submit(); // redirect to login page
    }
}

, ( , , ), , ASP.NET .

EDIT: , .aspx( , Silverlight). Silverlight, fooobar.com/questions/662951/....

+2

All Articles