Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

[Bug] Shell.Current.CurrentState.Location doesn't contain query parameters

Open powerdude opened this issue 3 years ago • 1 comments

Description

When using await Shell.Current.GotoAsync( "page?id=blah" ), query parameters don't seem to be preserved as part of Shell.Current.CurrentState.Location. It makes it difficult to have code like the following work since state can't be properly restored.

public partial class App
{
    protected override void OnStart()
    {
        var myRoute = Preferences.Get("my_route", "");

        if (myRoute != "")
        {
            Shell.Current.GoToAsync(myRoute);
        }
    }

    protected override void OnSleep()
    {
        var myRoute = Shell.Current.CurrentState.Location.ToString();
        Preferences.Set("my_route", myRoute);
    }
}

Steps to Reproduce

  1. Create a shell app
  2. Navigate to a page with a query parameter
  3. check value of Shell.Current.CurrentState.Location

Expected Behavior

Should have the query parameter(s) used to navigate to the page

Actual Behavior

Doesn't have the query parameters

Basic Information

  • Version with issue:
  • Last known good version:
  • Platform Target Frameworks:
    • iOS:
    • Android:
    • UWP:
  • Android Support Library / AndroidX Version:
  • NuGet Packages:
  • Affected Devices:

Environment

Show/Hide Visual Studio info

Build Logs

Screenshots

Reproduction Link

Workaround

powerdude avatar Mar 30 '22 20:03 powerdude

Hello! Did you find any workaround to get parameters?

kofanov avatar Oct 05 '23 16:10 kofanov