简体   繁体   中英

Windows Phone - NavigationService through app.xaml.cs

I am making app, where if you cannot get response connection from the server, you are redirected to a special page, which tells you something like "you cannot use your app without internet connection".

I am using API requests through several pages and places and from all of them, I want the same - redirecting to that special page. (so I do not want to place try-catch with same behaviour whenever I call api request)

Right now, I am throwing exception and my idea is to "catch" that exception at

private void Application_UnhandledException(object sender,ApplicationUnhandledExceptionEventArgs e)

Exception is throwed there, however now I do not know, how to redirect you from that point.

Also if you think, this is "not right", let me know too. However the app should be not operationable offline.

(I am using Windows Phone 8.0)


Edit : Well it is not possible to navigate from that point, the app drops :)

protected override void OnNavigatedTo(NavigationEventArgs e) { if (NetworkInterface.GetIsNetworkAvailable()) { your code.... } else { MessageBox.Show("no internet connection found...please check with your operator..."); } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM