[英]Getting notified when user exits browser in Silverlight application
我有一個Silverlight應用程序,用戶可以在其中登錄。 問題是某些用戶可能根本不注銷。 我想在我的應用程序中得到通知,以便我可以代表他注銷。 我一直在這里瀏覽,但沒有任何有效的解決方案。 我發現與此最相關的文章是: 如何在用戶嘗試關閉選項卡或關閉瀏覽器但無法獲得結果時通知用戶 。
誰能指出我,當用戶退出應用程序頁面或關閉應用程序中的瀏覽器時,如何通知我?
也許使用signal-R的解決方法會起作用。
如果用戶關閉瀏覽器或選項卡,則將調用OnDisconnected方法。
以下是一些更多信息: https : //www.codeproject.com/Tips/787033/SignalR-in-Silverlight
https://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-server#onreconnected
以下代碼幫助我解決了我的問題
public partial class App : Application
{
private MainPage mainPage;
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
}
private void Application_Exit(object sender, EventArgs e)
{
//Log out the current user when application exits
mainPage.LogoutCurrentUser();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.