注意1:.NET 8.0 中,支持 Blazor Web APP
注意2:.NET 6.0 、.NET 7.0 中,支持 Blazor Server 应用、Blazor WebAssembly 应用
一、Blazor Web APP
1、Routes.razor
主发包含 <Router> 组件,使用 <Found> 指定默认应用布局、路由等内容。
不再支持 <NotFound>,在 Program.cs 中使用下列语句代替
app.UseStatusCodePagesWithRedirects("/Error");
2、 App.razor
包含网页的 <html>、<head>、<body> 等内容。
包含 Routes.razor 组件:可在此组件中使用参数 @rendermode="InteractiveServer" 指定 rendermode,示例语句如下。
<Routes @rendermode="InteractiveServer" />
3、不再使用 _Layout.cshtml、_Host.cshtml 文件。
二、Blazor Server 应用
1、 App.razor
主发包含 <Router> 组件,使用 <Found>、<NotFound> 指定默认应用布局、路由等内容。
2、_Layout.cshtml
包含网页的 <html>、<head>、<body> 等内容。
3、_Host.cshtml
使用 <component> 指定 render-mode 。