maui
maui copied to clipboard
Maui Blazor Android cannot force loading addresses with query strings
Description
Maui Blazor Android cannot force loading addresses with query strings Navigation cannot be used on Android NavigateTo ($"/Login? ReturnUrl={Uri. EscapeDataString (Navigation. Uri)}", true); The forced loading result displays a message: "There is not content at Login" Debugging console displays "GET" https://0.0.0.0/Login?returnUrl=https%3A%2F%2F0.0.0.0%2F 404 (Not found)“
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
8.0.3
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 13
Did you find any workaround?
No response
Relevant log output
No response
Did this used to work in .NET 7.0?
Hi @Qiulin-Git. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
@mkArtakMSFT fyi
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
@Qiulin-Git I think query strings should work in Blazor Hybrid apps in .NET MAUI. Are you sure there is a Login.razor
or similar page in your app? Please post a repro app for us to investigate.
Sorry, I was recently hospitalized and unable to provide an example. My page is in the Razor library, and Maui and Wasm share the same UI
@Qiulin-Git I hope you get better soon.
In the meantime I built a sample app that shows that this should work: https://github.com/Eilon/maui19033AndroidQueryString
What might be missing is that when you have routable page Razor Components in a Razor Class Library (RCL) you have to let the Router know to find pages in that additional project/assembly/package. You can do that by specifying AdditionalAssemblies
in your app's Routers.razor
like this: https://github.com/Eilon/maui19033AndroidQueryString/blob/main/maui19033AndroidQueryString/Routes.razor#L5
And then in my app I added a pretend "login" button that redirects to the Login page in the RCL, passing in the current Uri
as the ReturnUrl
as a query string value: https://github.com/Eilon/maui19033AndroidQueryString/blob/main/maui19033AndroidQueryString/Components/Layout/NavMenu.razor#L31-L39
And then in the 'login' page once you click the button it redirects back to whatever the ReturnUrl
was (and it also shows it on the page): https://github.com/Eilon/maui19033AndroidQueryString/blob/main/LoginRazorClassLibrary1/Login.razor#L8-L22
Here's a short video recording of it working on the Android Emulator:
If you still can't get it working please let us know. For now I am closing this bug because it does appear to work.
@Eilon I have made the following changes to the NavigateToReturnUrl method in your sample application, which cannot run on Android
@Qiulin-Git can you post a complete repro app to a public GitHub repo? That will help us investigate because otherwise we couldn't find any other issue in this scenario. Thanks!
Hi @Qiulin-Git. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
@Eilon I built a sample application : https://github.com/Qiulin-Git/MauiAppAndroidQueryString Jump to login page when there is no login in the router, unable to jump in Android
@Qiulin-Git thank you I can repro it with your app now on Android (but Windows is fine).
Note for my future self, the logs seem to indicate it is looking for the Login view, which should be fine, yet somehow the StaticContentProvider is being invoked and reports that there is no content.
These are the logs:
[0:] Microsoft.AspNetCore.Components.RenderTree.Renderer: Debug: Rendering component 13 of type Microsoft.AspNetCore.Components.Authorization.AuthorizeView
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Navigation event for URI 'https://0.0.0.0/Login?returnUrl=https%3A%2F%2F0.0.0.0%2F' with URL loading strategy 'OpenInWebView'.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Handling web request to URI 'https://0.0.0.0/Login'.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Response content being sent for web request to URI 'https://0.0.0.0/Login' with HTTP status code 404.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Handling web request to URI 'https://0.0.0.0/favicon.ico'.
[0:] Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler: Debug: Response content being sent for web request to URI 'https://0.0.0.0/favicon.ico' with HTTP status code 404.
And this is what's reporting the error: https://github.com/dotnet/aspnetcore/blob/main/src/Components/WebView/WebView/src/StaticContentProvider.cs#L48-L51
But I don't think it should even be going to the static content provider, because the /Login
URL is a content page, not static content...
I can repro it on the latest 17.10.0 Preview 1.0.