PushAsync is not supported globally on Android, please use a NavigationPage - Xamarin.Forms

You are calling "PushAsync":

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
    }

    private void btnCourseList_Clicked(object sender, EventArgs e)
    {
        Navigation.PushAsync(new PageB());
    }
}

but you did not start the NavigationPage, which normally is done in the App.cs class, or at least it should be started before any call to "PushAsync":

MainPage = new NavigationPage(new PageA());

In app.xaml.cs file,

Replace

 MainPage = new <namespace>.MainPage();

With

 MainPage = new NavigationPage(new <namespace>.MainPage());

Then Use

 await Navigation.PushAsync(new NavigationPage(new MainPage2()));

You need to enclose your LoginPage in a NavigationPage. This will fix your error, but will leave you with the LoginPage contained on your navigation stack.

An alternate approach would be to make your HomePage the root of the application, then display the LoginPage modally on top of it. Only when the user successfully logs in do you dismiss the LoginPage modal so they can see the HomePage.


I only change pushAsync with pushModalAsync :)

public async void LogIn(object sender, EventArgs eventsArgs)
{
    //do authenticate stuff here
    SSO.MyAuthentication client = new SSO.MyAuthentication();

    bool isAuthenticated = client.Authenticate(_UsernameInput.Text, _PasswordInput.Text);

    if(isAuthenticated)
    {
         //Push home page to top of navigation stack
         //Navigation.PushAsync(new HomePage());
           Navigation.PushModalAsync(new HomePage());
    }
}

First make setting in "Main App Page" then do in "Content page" to go other page:

enter image description here