blazor

Can the state of the Counter in the example Blazor project be preserved between page switches?

半世苍凉 提交于 2020-06-26 14:05:42
问题 In the default example project for both server-side Blazor and WebAssembly Blazor projects, the Counter example resets to 0 every time you move between the pages. However, on the ASP.NET React example project, the Counter does not reset between page switches. Is there a way for a component like the Counter to preserve state between page navigation in Blazor (at least for the WebAssembly project that isn't making any server calls)? 回答1: It looks like this exact scenario is discussed in https:/

Can the state of the Counter in the example Blazor project be preserved between page switches?

旧街凉风 提交于 2020-06-26 14:05:34
问题 In the default example project for both server-side Blazor and WebAssembly Blazor projects, the Counter example resets to 0 every time you move between the pages. However, on the ASP.NET React example project, the Counter does not reset between page switches. Is there a way for a component like the Counter to preserve state between page navigation in Blazor (at least for the WebAssembly project that isn't making any server calls)? 回答1: It looks like this exact scenario is discussed in https:/

Why are Blazor lifecycle methods getting executed twice?

倾然丶 夕夏残阳落幕 提交于 2020-06-25 09:17:31
问题 So with a release of asp.net core 3.0 and blazor 1.0 I started doing some actual work with blazor. When splitting Blazor component code into code behind I am using the following public class LogoutModel : BlazorComponent { } Unfortunatelly BlazorComponent does not exist anymore, so I move to ComponentBase. Not sure when did this change took place.. Now the rest of my code looks like this public class LogoutModel : ComponentBase { protected override async Task OnInitializedAsync() { }

Processing unhandled exceptions in ASP.NET Core 3.1

自作多情 提交于 2020-06-24 14:58:05
问题 In ASP.NET Core 3.1 a feature was added where unhandled exceptions can be passed onto an instance of ILogger as noted here: Logging in .NET Core and ASP.NET Core I have a Server side Blazor website where I want to be able to process these exceptions in a function where I can log them to a database or perhaps send an email. However I am unable to come up with code to do this based on the provided documentation. Could someone provide sample code to trap unhandled exceptions? 回答1: I recommand to

Blazor WebAssembly + Amazon Cognito

只谈情不闲聊 提交于 2020-06-23 12:36:27
问题 I would like to set up a Blazor client-side app with authentication through AWS Cognito . When I run the app I'm not redirected to a login page, instead the page says "Authorizing..." for a few seconds, while I get this error in the console: The loading of “https://blazorapp.auth.eu-central-1.amazoncognito.com/login?…Q&code_challenge_method=S256&prompt=none&response_mode=query” in a frame is denied by “X-Frame-Options“ directive set to “DENY“. This error page has no error code in its security

Using Blazor components from a Shared Library in an ASP.NET Core Web Application (IdentityServer project)

陌路散爱 提交于 2020-06-17 22:54:21
问题 Recently I created a new Blazor Webassembly project including Authentication (Individual User Accounts) and ASP.NET Core hosted. This generated 3 projects for me, namely: Client (Blazor Webassembly), Server (where the authentication stuff resides in, using Identityserver - looks like a ASP.NET Core Web Application template using MVC / Razor) and a Shared project. I want all my components to be reused easily so I also created a Razor Class Library where my (Blazor) components reside in. In

Why doesnt the page preserve the data?

独自空忆成欢 提交于 2020-06-17 15:49:17
问题 So I'm currently looking at the Blazor example project.. The "Counter" to be more specific, and when I increment the value on the page, and then click a different tab on the webapp, let's say the "Fetch data" tab which pulls up the weather, and then I go back, the value that was incremented is back to 0.. Why is that? Why isn't it saved? Here is the NavMenu <div class="@NavMenuCssClass" @onclick="ToggleNavMenu"> <ul class="nav flex-column"> <li class="nav-item px-3"> <NavLink class="nav-link"

EditForm - How can I prevent submit on pressing enter key

纵然是瞬间 提交于 2020-06-17 02:51:11
问题 I've found this article but I'm having a hard time to understand how can I prevent submit on "enter" key independently by any <input> <EditForm Model="exampleModel" OnValidSubmit="HandleValidSubmit"> <DataAnnotationsValidator /> <ValidationSummary /> <InputText id="name" @bind-Value="exampleModel.Name" /> <InputText id="name2" @bind-Value="exampleModel.Name2" /> <button type="submit">Submit</button> </EditForm> @code { private ExampleModel exampleModel = new ExampleModel(); private void

EditForm - How can I prevent submit on pressing enter key

。_饼干妹妹 提交于 2020-06-17 02:51:07
问题 I've found this article but I'm having a hard time to understand how can I prevent submit on "enter" key independently by any <input> <EditForm Model="exampleModel" OnValidSubmit="HandleValidSubmit"> <DataAnnotationsValidator /> <ValidationSummary /> <InputText id="name" @bind-Value="exampleModel.Name" /> <InputText id="name2" @bind-Value="exampleModel.Name2" /> <button type="submit">Submit</button> </EditForm> @code { private ExampleModel exampleModel = new ExampleModel(); private void

Detect client closing connection Blazor

扶醉桌前 提交于 2020-06-16 17:07:10
问题 I have a loop that I have got running the whole time the client is on the page but I got no way to close the loop so that always remains running even when the user already disconnected. Is there a lifecycle method that runs when the user closes the connection? or is there a different way? 回答1: I'm not sure just implementing the IDisposable Interface can help you here, but implementing the Blazor Server circuit handler may. I vaguely recall that a similar question to yours was asked in