For several of the sites I have built using MVC/TypeScript or MVC/Angular I have needed to redirect the user immediately from http://hostname to http://hostname/route1. I am trying to figure out how to implement the same functionality with Blazor Server Side.
I am aware that this can be done using the IIS URL Rewrite engine, however, it has not been determined if the application will be hosted under IIS, self-hosted on Windows, or hosted on Linux.
Is this possible?
I changed MainLayout.razor to override the OnInitialized method.
@inject NavigationManager MyNavigationManager
@code
{
protected override void OnInitialized()
{
var currentUri = new Uri(MyNavigationManager.Uri);
if (currentUri.AbsolutePath == "/")
MyNavigationManager.NavigateTo("route1");
}
}