blazor

What's the difference between RenderMode.Server and RenderMode.ServerPrerendered in blazor?

依然范特西╮ 提交于 2020-05-29 03:28:21
问题 What's the difference between @(await Html.RenderComponentAsync<Todo>(RenderMode.ServerPrerendered)) and @(await Html.RenderComponentAsync<Todo>(RenderMode.Server)) I was looking into the documentation but couldn't really find something that explains the difference. and also don't really understand the code comments over the enum stating: // Summary: // Renders a marker for a Blazor server-side application. This doesn't include any // output from the component. When the user-agent starts, it

Auto reconnect Blazor Serverside

佐手、 提交于 2020-05-28 14:48:27
问题 Blazor serverside (dotnet core 3.1) I run into the problem that on customer side this is shown: Could not reconnect to the server. Reload the page to restore functionality. Each time I update the Codebase or Internet is broken or something like this. Now the goal is that it should reload the page as soon as the server is back again (or in some interval). Is there any possibility / github repo or something like this that could help me? Thx! 回答1: You can try this code: <script src="_framework

Auto reconnect Blazor Serverside

余生颓废 提交于 2020-05-28 14:48:06
问题 Blazor serverside (dotnet core 3.1) I run into the problem that on customer side this is shown: Could not reconnect to the server. Reload the page to restore functionality. Each time I update the Codebase or Internet is broken or something like this. Now the goal is that it should reload the page as soon as the server is back again (or in some interval). Is there any possibility / github repo or something like this that could help me? Thx! 回答1: You can try this code: <script src="_framework

Execute async method on button click in blazor

浪子不回头ぞ 提交于 2020-05-28 13:42:53
问题 I created a "Razor Components" project. I am trying to execute an asynchronous method when pressing a button, but could not figure out the syntax yet. This is my Index.razor : @page "/" @inject GenericRepository<Person> PersonRepository // ... @foreach (var person in persons) { <button onclick="@(() => Delete(person.Id))">❌</button> } @functions { // ... async void Delete(Guid personId) { await this.PersonRepository.Delete(personId); } } When I click the button, nothing happens. I tried

Execute async method on button click in blazor

蓝咒 提交于 2020-05-28 13:42:39
问题 I created a "Razor Components" project. I am trying to execute an asynchronous method when pressing a button, but could not figure out the syntax yet. This is my Index.razor : @page "/" @inject GenericRepository<Person> PersonRepository // ... @foreach (var person in persons) { <button onclick="@(() => Delete(person.Id))">❌</button> } @functions { // ... async void Delete(Guid personId) { await this.PersonRepository.Delete(personId); } } When I click the button, nothing happens. I tried

HandleRequirementAsync not being called in Auth handler in Blazor app

会有一股神秘感。 提交于 2020-05-28 07:34:40
问题 Im trying to come to grips with using a custom auth handler in a serverside Blazor app. I have a breakpoint in my handler, but its not getting hit. Whats missing? Requirement public class ValidUserRequirement : IAuthorizationRequirement { public bool MustBeValid { get; } public ValidUserRequirement(bool IsValid) { MustBeValid = IsValid; } } Policies public static class Policies { public const string IsValidUser = "IsValidUser"; public static AuthorizationPolicy IsValidUserPolicy() { return

HandleRequirementAsync not being called in Auth handler in Blazor app

跟風遠走 提交于 2020-05-28 07:34:07
问题 Im trying to come to grips with using a custom auth handler in a serverside Blazor app. I have a breakpoint in my handler, but its not getting hit. Whats missing? Requirement public class ValidUserRequirement : IAuthorizationRequirement { public bool MustBeValid { get; } public ValidUserRequirement(bool IsValid) { MustBeValid = IsValid; } } Policies public static class Policies { public const string IsValidUser = "IsValidUser"; public static AuthorizationPolicy IsValidUserPolicy() { return

HandleRequirementAsync not being called in Auth handler in Blazor app

时光总嘲笑我的痴心妄想 提交于 2020-05-28 07:33:45
问题 Im trying to come to grips with using a custom auth handler in a serverside Blazor app. I have a breakpoint in my handler, but its not getting hit. Whats missing? Requirement public class ValidUserRequirement : IAuthorizationRequirement { public bool MustBeValid { get; } public ValidUserRequirement(bool IsValid) { MustBeValid = IsValid; } } Policies public static class Policies { public const string IsValidUser = "IsValidUser"; public static AuthorizationPolicy IsValidUserPolicy() { return

HandleRequirementAsync not being called in Auth handler in Blazor app

大城市里の小女人 提交于 2020-05-28 07:33:31
问题 Im trying to come to grips with using a custom auth handler in a serverside Blazor app. I have a breakpoint in my handler, but its not getting hit. Whats missing? Requirement public class ValidUserRequirement : IAuthorizationRequirement { public bool MustBeValid { get; } public ValidUserRequirement(bool IsValid) { MustBeValid = IsValid; } } Policies public static class Policies { public const string IsValidUser = "IsValidUser"; public static AuthorizationPolicy IsValidUserPolicy() { return

How to reset custom validation errors when using editform in blazor razor page

蓝咒 提交于 2020-05-27 06:26:31
问题 I have an editform using an editcontext: <EditForm OnValidSubmit="HandleValidSubmit" EditContext="_editContext" Context="auth"> <DataAnnotationsValidator /> <input type="time" @bind-value="_foodTruck.EndDelivery" @onkeydown="@(q=>ResetValidation("EndDelivery"))" > <ValidationMessage For="() => _foodTruck.EndDelivery" /> <input type="time" @bind-value="_foodTruck.StartDelivery" @onkeydown="@(q=>ResetValidation("StartDelivery"))" > <ValidationMessage For="() => _foodTruck.StartDelivery" />