Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Navigation PopAsync throwing Invalid State Exception

$
0
0

I want to be able to check if user is authenticated whenever a new view comes up. So I placed the checkauthentication code in the OnAppearing event of my base view (which is an abstract class). Here is the code-

protected override void OnAppearing ()
    {
        base.OnAppearing ();
        CheckAuthentication ();

    }

If the CheckAuthentication method returns false then I use Navigation.PushModalAsync to pop open the login view. Once user enters credentials, I popmodal async to dismiss the login view.

Now I also have logout function on each of my other views. When user clicks logout, then I send a message to BaseViewModel to show loginview using following function-

Navigation.PushModalAsync<LoginViewModel>();

User enters credentials and then I use the same code as mentioned above Navigation.PopModalAsync() to dismiss loginview. But here I am getting following exception-

"Operation is not valid due to the current state of the object"

Please note that logic of dismissing the loginview is placed in baseviewmodel class which is again an abstract class.

Not sure if I have designed it correctly or why I am getting this exception.

Thanks

Apurva


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>