Skip to content

Commit 68d0625

Browse files
authored
NodeDev.Blazor.Server now using newer .net 8+ layout of Blazor without needing any cshtml files (#55)
1 parent 0818885 commit 68d0625

File tree

6 files changed

+52
-65
lines changed

6 files changed

+52
-65
lines changed

src/NodeDev.Blazor.Server/App.razor

+32-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
1-
<Router AppAssembly="@typeof(App).Assembly">
2-
<Found Context="routeData">
3-
<RouteView RouteData="@routeData" />
4-
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
5-
</Found>
6-
<NotFound>
7-
<PageTitle>Not found</PageTitle>
8-
<LayoutView>
9-
<p role="alert">Sorry, there's nothing at this address.</p>
10-
</LayoutView>
11-
</NotFound>
12-
</Router>
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<base href="/" />
7+
8+
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
9+
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
10+
<link href="_content/NodeDev.Blazor/styles.css" rel="stylesheet" />
11+
12+
<link href="_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.css" rel="stylesheet" />
13+
14+
<link href="_content/Z.Blazor.Diagrams/style.min.css" rel="stylesheet" />
15+
<link href="_content/Z.Blazor.Diagrams/default.styles.min.css" rel="stylesheet" />
16+
</head>
17+
<body style="width: 100vw; height: 100vh">
18+
19+
<Routes @rendermode="InteractiveServer" />
20+
21+
<script src="_content/BlazorMonaco/jsInterop.js"></script>
22+
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"></script>
23+
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js"></script>
24+
25+
<script src="_framework/blazor.web.js"></script>
26+
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
27+
28+
<script src="_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.js"></script>
29+
30+
<script src="_content/Z.Blazor.Diagrams/script.min.js"></script>
31+
</body>
32+
</html>

src/NodeDev.Blazor.Server/Pages/_Host.cshtml

-8
This file was deleted.

src/NodeDev.Blazor.Server/Pages/_Layout.cshtml

-37
This file was deleted.

src/NodeDev.Blazor.Server/Program.cs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
using Microsoft.AspNetCore.Components;
2-
using Microsoft.AspNetCore.Components.Web;
1+
using NodeDev.Blazor.Server;
32
using NodeDev.Blazor.Services;
43

54
var builder = WebApplication.CreateBuilder(args);
65

76
// Add services to the container.
8-
builder.Services.AddRazorPages();
9-
builder.Services.AddServerSideBlazor();
7+
builder.Services.AddRazorComponents()
8+
.AddInteractiveServerComponents();
109

1110
builder.Services.AddNodeDev();
1211

@@ -20,11 +19,11 @@
2019
app.UseHsts();
2120
}
2221

23-
app.UseStaticFiles();
22+
app.UseAntiforgery();
2423

25-
app.UseRouting();
24+
app.UseStaticFiles();
2625

27-
app.MapBlazorHub();
28-
app.MapFallbackToPage("/_Host");
26+
app.MapRazorComponents<App>()
27+
.AddInteractiveServerRenderMode();
2928

3029
app.Run();
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Router AppAssembly="@typeof(App).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" />
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
5+
</Found>
6+
<NotFound>
7+
<PageTitle>Not found</PageTitle>
8+
<LayoutView>
9+
<p role="alert">Sorry, there's nothing at this address.</p>
10+
</LayoutView>
11+
</NotFound>
12+
</Router>

src/NodeDev.Blazor.Server/_Imports.razor

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
@using Microsoft.AspNetCore.Components.Routing
66
@using Microsoft.AspNetCore.Components.Web
77
@using Microsoft.AspNetCore.Components.Web.Virtualization
8+
@using static Microsoft.AspNetCore.Components.Web.RenderMode
89
@using Microsoft.JSInterop
910
@using NodeDev.Blazor.Server

0 commit comments

Comments
 (0)