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
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<Routes />
|
||||
<Routes @rendermode="InteractiveServer" />
|
||||
<ReconnectModal />
|
||||
<script src="@Assets["_framework/blazor.web.js"]"></script>
|
||||
</body>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
@page "/register"
|
||||
@using Blazored.LocalStorage
|
||||
@using Sandbox.Models.ViewModels
|
||||
|
||||
@inject Sandbox.App.Services.AuthService.IAuthService AuthService
|
||||
@inject ILocalStorageService LocalStorageService
|
||||
|
||||
<title>Register</title>
|
||||
|
||||
<EditForm Model="user" OnValidSubmit="HandleRegistration" OnInvalidSubmit="HandleInvalidSubmit" FormName="registerForm">
|
||||
<EditForm Model="user" OnValidSubmit="HandleRegistration" OnInvalidSubmit="HandleInvalidSubmit">
|
||||
<DataAnnotationsValidator/>
|
||||
<div class="d-flex justify-content-center align-items-center">
|
||||
<div class="col-md-4 p-5 shadow-sm border rounded-3">
|
||||
@@ -39,6 +41,10 @@
|
||||
</div>
|
||||
</EditForm>
|
||||
|
||||
<div class="text-info">
|
||||
@RendererInfo.Name
|
||||
</div>
|
||||
|
||||
<div class="text-danger">
|
||||
<span>@errorMessage</span>
|
||||
</div>
|
||||
@@ -48,7 +54,7 @@
|
||||
</div>
|
||||
|
||||
@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()
|
||||
|
||||
@@ -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<ClientServices.AuthService.IAuthService, ClientServices.AuthService.AuthService>();
|
||||
|
||||
|
||||
@@ -9,4 +9,8 @@
|
||||
<BlazorDisableThrowNavigationException>true</BlazorDisableThrowNavigationException>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazor.Storage" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
24
blazor-server-mini-sandbox.sln
Normal file
24
blazor-server-mini-sandbox.sln
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user