I am trying to set a route in Blazor (Server) (.NET 8) using Visual Studio 2022. I have just created a new project and modified the code of Routes.razor file as
<Router AppAssembly="typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
<FocusOnNavigate RouteData="routeData" Selector="h1" />
</Found>
*<NotFound>
<LayoutView Layout="@typeof(Layout.MainLayout)">
<h1>Heyy</h1>
</LayoutView>
</NotFound>*
</Router>
Program.cs
using BlazorApp2.Components;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run();
I am just following the documentation and videos on web on working with Blazor, still I am getting the browser’s regular Invalid Page.
Is there anything new added or deprecated function in Blazor?