XAMARIN FORMS (Android) - App is kicked out after successfull user validation

KhaiFMsia 71 Reputation points
2022-05-09T02:12:51.347+00:00

I have a button
<Button Text="LOGIN" Clicked="ProceedLogin" x:Name="BtnLogin" />

After button clicked, it will check my API to validate user credential, if success, then the app should navigate to the next page, but it just kicked out. Already try catch also not show any error, just KICKED OUT. Need some advise from experts here. Thank you.

private async void ProceedLogin(object sender, EventArgs e)
    {

        Detail user = new Detail
        {
            usrId = myId.Text,
            usrPassword = myPwd.Text
        };

        string getlogin = await client.GetStringAsync("*<call my webapi to validate user>*");

        Login login = JsonConvert.DeserializeObject<Login>(getlogin);
        if (login.PromptMessage != "")
        {
            this.IsBusy = false;
            BtnLogin.IsEnabled = true;
            await DisplayAlert("", login.PromptMessage, DisplayErrorMessage("6"));
            return;
        }
        else
        {
            Application.Current.Properties["isLogged"] = true;
            Application.Current.MainPage = new NavigationPage(new PageNotice());  //should go to next page
            (PageNotice) 

        }

    }
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
{count} votes