Have easy way to set initial BlazorWebView URL #11746
Labels
area-blazor
Blazor Hybrid / Desktop, BlazorWebView
fixed-in-8.0.0-preview.1.7762
Look for this fix in 8.0.0-preview.1.7762!
t/enhancement ☀️
New feature or request
Milestone
Background
When BlazorWebView initializes Blazor itself, the first thing it does is navigate to
/
(examples: MAUI Windows, MAUI Android, WinForms).If you want the initial URL to be something different, you have to do it entirely manually, which in my view is not so obvious.
It's useful to have a custom start page when your app is built around one main Razor component that represents the app, but you want to take the user straight to a specific page within the Blazor navigation space. This could be due to deep-linking from an external location, multi-window apps (e.g. pop open a new window to show a specific order's details, etc.).
Workaround
Here's how to do it manually in MAUI (very similar on WinForms/WPF as well):
Main.razor
file to accept an optionalStartPath
property, and callNavigationManager.NavigateTo
if it is set:MainPage.xaml.cs
set the root component's parameters to indicate which, if any, custom start path to use:Proposal
This could possibly be done more easily if each
BlazorWebView
control had a newStartPath
property that would be used for the initial navigation (instead of always navigating to/
):The text was updated successfully, but these errors were encountered: