The startup page in my Blazor application is Index.cshtml. I'd like to change the startup page to the homepage, namely my Home.cshtml.
I'm using vs2019, ASPNET CORE Blazor (0.9.0-preview3-19154-020).
Blazor Serverside has routing in the Startup.cs, which i think is for the services, and not for the pages...and is left as generated by creating a new Blazor project.
app.UseMvc(routes => { routes.MapRoute(name: "default", template: "{controller}/{action}/{id?}"); });
The client's startup has (as generated by a new Blazor project):
public void ConfigureServices(IServiceCollection services) { } public void Configure(IComponentsApplicationBuilder app) { app.AddComponent<App>("app"); }
Do I need to register the routing in the client side startup.cs somehow?
the index.cshtml only has one line of code in it:
@page "/"
How do I change my 'startup' page from Index.cshtml to Home.cshtml?
I've looked in a lot of places and understand Blazor is 'experimental'. Feels like i'm working way to hard to change something this simple.
Configure a manual start in the wwwroot/index. html file (Blazor WebAssembly) or Pages/_Layout. cshtml file (Blazor Server): Add an autostart="false" attribute and value to the <script> tag for the Blazor script.
Yes, Blazor is ready to be used in production, it is a life changer, Blazor is a framework that optimizes development speed, helps considerably reducing code duplication and inconsistencies between front-end and api/backend models, and in turn it helps reducing bugs and development costs, in top of that, since Blazor ...
If you were considering a Windows desktop application (built on something like WPF), Blazor is a more future-forward choice. But if you're a business building modern, public web applications, there's very little chance you'll recommend a client start with Blazor today.
You can get the current page title in Blazor by using the “title” property of the document object in JavaScript and by using a . JavaScript interop since there is no DOM accessibility in Blazor.
Just put @page "/" on top of your page you want to be default. Remove @page "/" from Index.razor
@page "/" @page "/fetchdata"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With