From 88e02c27ee35b9a7070bfacb6ecf14cf6067e86f Mon Sep 17 00:00:00 2001 From: postb99 Date: Fri, 6 Feb 2026 22:14:45 +0100 Subject: [PATCH] Activate InteractiveServer rendermode to whole app, add and use Blazor.Storage package, display current render mode, remove added stuff that was required for static rendering --- Components/App.razor | 2 +- Components/Pages/Account/Register.razor | 12 ++++++++++-- Program.cs | 4 ++++ blazor-server-mini-sandbox.csproj | 4 ++++ blazor-server-mini-sandbox.sln | 24 ++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 blazor-server-mini-sandbox.sln diff --git a/Components/App.razor b/Components/App.razor index 7900579..b66b6c1 100644 --- a/Components/App.razor +++ b/Components/App.razor @@ -15,7 +15,7 @@ - + diff --git a/Components/Pages/Account/Register.razor b/Components/Pages/Account/Register.razor index fee8c2a..00b492d 100644 --- a/Components/Pages/Account/Register.razor +++ b/Components/Pages/Account/Register.razor @@ -1,11 +1,13 @@ @page "/register" +@using Blazored.LocalStorage @using Sandbox.Models.ViewModels @inject Sandbox.App.Services.AuthService.IAuthService AuthService +@inject ILocalStorageService LocalStorageService Register - +
@@ -39,6 +41,10 @@
+
+ @RendererInfo.Name +
+
@errorMessage
@@ -48,7 +54,7 @@
@code { - [SupplyParameterFromForm] private UserRegister user { get; set; } + private UserRegister user { get; set; } private string message = string.Empty; private string messageCssClass = string.Empty; @@ -61,6 +67,8 @@ var result = await AuthService.Register(user); message = result.Message; messageCssClass = result.Success ? "text-success" : "text-danger"; + + await LocalStorageService.SetItemAsync("test", message); } async Task HandleInvalidSubmit() diff --git a/Program.cs b/Program.cs index 7aca213..70c76d0 100644 --- a/Program.cs +++ b/Program.cs @@ -1,3 +1,4 @@ +using Blazored.LocalStorage; using Sandbox; using Sandbox.Components; using Sandbox.Models.ViewModels; @@ -10,6 +11,9 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); +// Blazor.Storage +builder.Services.AddBlazoredLocalStorage(); + // Blazor client services builder.Services.AddScoped(); diff --git a/blazor-server-mini-sandbox.csproj b/blazor-server-mini-sandbox.csproj index aa45a32..25f7912 100644 --- a/blazor-server-mini-sandbox.csproj +++ b/blazor-server-mini-sandbox.csproj @@ -9,4 +9,8 @@ true + + + + diff --git a/blazor-server-mini-sandbox.sln b/blazor-server-mini-sandbox.sln new file mode 100644 index 0000000..060f387 --- /dev/null +++ b/blazor-server-mini-sandbox.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "blazor-server-mini-sandbox", "blazor-server-mini-sandbox.csproj", "{A4595977-F945-77FD-CAC9-1B945F061E97}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A4595977-F945-77FD-CAC9-1B945F061E97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4595977-F945-77FD-CAC9-1B945F061E97}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4595977-F945-77FD-CAC9-1B945F061E97}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4595977-F945-77FD-CAC9-1B945F061E97}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {08319A16-FD23-406A-9429-7EA3AFE8A9DD} + EndGlobalSection +EndGlobal