Shell Navigation doesn't render the next page on Android. Shell Current State shows DnsSafeHost - System Invalid Exception.

Khadeeja Madathil 0 Reputation points
2024-07-02T15:49:46.3433333+00:00

Shell Navigation doesn't render the next page on Android. Shell Current State shows DnsSafeHost - System Invalid Exception.

The steps -

Have set the AppShell as MainPage

MainPage = new AppShell();

Routing registered for second page on AppShell.xaml.cs

Routing.RegisterRoute("secondpage", typeof(SecondPage));

  1. From the initial page, tries to navigate to next page on button click

private void Button_OnClicked(object sender, EventArgs e) { Shell.Current.GoToAsync("secondpage"); }

Behavior -

The breakpoint redirects to the second page. But UI is never rendered.

When checked the current state of the Shell, I get the following result -

Shell Navigation doesn't render the next page on Android. Shell Current State shows DnsSafeHost - System Invalid Exception.

The steps -

Have set the AppShell as MainPage

MainPage = new AppShell();

Routing registered for second page on AppShell.xaml.cs

Routing.RegisterRoute("secondpage", typeof(SecondPage));

  1. From the initial page, tries to navigate to next page on button click

private void Button_OnClicked(object sender, EventArgs e)
{
Shell.Current.GoToAsync("secondpage");
}

Behavior -

The breakpoint redirects to the second page. But UI is never rendered.

When checked the current state of the Shell, I get the following result -

Screenshot 2024-07-02 at 16.38.12

Dns safe host - System Invalid Exception.

When checked the state when just after setting Shell, gives the same result. No crashes or errors. Just the navigation is blocked.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,207 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 38,911 Reputation points Microsoft Vendor
    2024-07-03T05:29:34.4266667+00:00

    Hello,

    GoToAsync is an asynchronous method, so you need to use await so that the method can execute as expected to complete this statement.

    private async void Button_OnClicked(object sender, EventArgs e)
    {
        await Shell.Current.GoToAsync("secondpage");
    }
    

    After testing, using this method does not cause the problem of a blank UI on the second page.

    You can refer to Asynchronous programming scenarios for more information on asynchronous programming.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.