Quantcast
Viewing latest article 1
Browse Latest Browse All 5

Answer by calingasan for Setting a startup page in Blazor

You do not need to configure routing on your startup. Routing just works per razor page. What ever you put on @page is the routing path for that razor page e.g. Index.razor route to root path "/".

@page "/"<h1>Index Page</h1>@code {    //Code here..}

Its not a good idea having the same route for different razor pages so, if you want to use the root path on the Home.razor page, make sure you change the Index.razor to a different route.

If what you want is a redirect, let say, instead of having your site load at www.yourdomain.com, you want it to load at www.yourdomain.com/home then you can do the following on your Index.razor

@page "/"@inject NavigationManager NavManager<h1>Index Page</h1>@code {    protected override void OnInitialized()    {        NavManager.NavigateTo("/home");    }}

This assumes that you also have the following route on your Home.razor

@page "/home"<h1>Index Page</h1>@code {    //Code here..}

Viewing latest article 1
Browse Latest Browse All 5

Trending Articles