2012-07-20 37 views
1

我有一個Silverlight應用程序與自定義窗體身份驗證。 當瀏覽器窗口關閉時,我該如何註銷應用程序?如何在Silverlight應用程序中註銷應用程序退出?

我想是這樣的:

public App() 
    { 
     Startup += ApplicationStartup; 
     Exit += Application_Exit; 

     UnhandledException += ApplicationUnhandledException; 
     var webContext = new WebContext {Authentication = new FormsAuthentication()}; 
     ApplicationLifetimeObjects.Add(webContext); 
     InitializeComponent(); 
    } 

    private void ApplicationStartup(object sender, StartupEventArgs e) 
    { 
     Resources.Add("WebContext", WebContext.Current); 
     RootVisual = new MainPage(); 
    } 

    private void Application_Exit(object sender, EventArgs e) 
    { 
     WebContext.Current.Authentication.Logout(false); 
    } 

但這並沒有工作。 Ewery時間我關閉瀏覽器,我收到異常一個AsyncCallback拋出一個異常沒有任何細節。

我該如何處理這個問題?

回答

0

你可以用onbeforeunload在頁面上調用一個ajax調用,忘記在silverlight關閉時用silverlight調用註銷的想法。