Skip to content

Blazor Hybrid Webview cannot be force reloaded for urls containing query parameters with a dot (.) #25689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
modplug opened this issue Nov 5, 2024 · 1 comment · May be fixed by #29560
Open
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView good first issue Good for newcomers platform/android platform/ios s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@modplug
Copy link
Contributor

modplug commented Nov 5, 2024

Description

There is an issue in Blazor MAUI where URLs containing a query parameter with a dot (.) cannot be force reloaded.

The issue stems from the Path.HasExtension method, which incorrectly identifies the query parameter as a file extension. This causes the URL to be treated as a file path, leading to unexpected behavior when attempting a force reload.

Path.HasExtension is being used from [UriExtensions] in BlazorWebView (https://github.com/dotnet/maui/blob/main/src/BlazorWebView/src/Maui/Extensions/UriExtensions.cs)

Steps to Reproduce

Steps to Reproduce

  • Clone the repository
  • Open the solution
  • Run the application on iOS or Android
  • Navigate to the home page
  • Click on the link to force a refresh/reload for the current page with query parameters.
  • Observe the application navigating to a empty webpage with a "There is no content at url" message.

Link to public reproduction project repository

https://github.com/modplug/HybridMauiQueryParamsFailureRepro

Version with bug

8.0.92 SR9.2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

I haven't been able to find a way around this since the url parsing and navigation is internal in

Relevant log output

private void TestIfUrlIsBaseOfPage()
    {
        var urlWithoutQueryParameterWithDot = "https://example.com/customer?weight=62";
        var urlWithQueryParameterWithDot = "https://example.com/customer?weight=62.5";

        var isAddressWithoutDotBaseOfPage = new Uri("https://example.com").IsBaseOfPage(urlWithoutQueryParameterWithDot); // true
        var isAddressWithDotBaseOfPage = new Uri("https://example.com").IsBaseOfPage(urlWithQueryParameterWithDot); // false but expected true

        var isAddressWithoutDotAFilePath = Path.HasExtension(urlWithoutQueryParameterWithDot); // false
        var isAddressWithDotAFilePath = Path.HasExtension(urlWithQueryParameterWithDot); // true but expected false

        Console.WriteLine($"{urlWithoutQueryParameterWithDot}: {nameof(isAddressWithoutDotBaseOfPage)}: {isAddressWithoutDotBaseOfPage}");
        Console.WriteLine($"{urlWithQueryParameterWithDot}: {nameof(isAddressWithDotBaseOfPage)}: {isAddressWithDotBaseOfPage}");
        Console.WriteLine($"{urlWithoutQueryParameterWithDot}: {nameof(isAddressWithoutDotAFilePath)}: {isAddressWithoutDotAFilePath}");
        Console.WriteLine($"{urlWithQueryParameterWithDot}: {nameof(isAddressWithDotAFilePath)}: {isAddressWithDotAFilePath}");
    }

this outputs:
https://example.com/customer?weight=62: isAddressWithoutDotBaseOfPage: True
https://example.com/customer?weight=62.5: isAddressWithDotBaseOfPage: False
https://example.com/customer?weight=62: isAddressWithoutDotAFilePath: False
https://example.com/customer?weight=62.5: isAddressWithDotAFilePath: True
@modplug modplug added the t/bug Something isn't working label Nov 5, 2024
@jfversluis jfversluis added the area-blazor Blazor Hybrid / Desktop, BlazorWebView label Nov 5, 2024
@ninachen03 ninachen03 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Nov 6, 2024
@ninachen03
Copy link

This issue has been verified using Visual Studio 17.12.0 Preview 5( 8.0.92 & 8.0.3). Can repro this issue.
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView good first issue Good for newcomers platform/android platform/ios s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants