blazor

Blazor preventDefault on submit form

余生长醉 提交于 2020-07-10 02:52:28
问题 Inside my EditForm , I want to prevent that the user submits the form by pressing the Enter key. I have tried the following, but didn't work. <button type="submit" @onkeypress:preventDefault>Save</button> Many thanks! 回答1: I have got this working by just putting 2 submit button's in the EditForm , with the first one disabled. <button type="submit" disabled style="display: none" aria-hidden="true"></button> <button type="submit">Save</button> 回答2: Here's a working code sample, run it and see

Blazor preventDefault on submit form

别说谁变了你拦得住时间么 提交于 2020-07-10 02:52:24
问题 Inside my EditForm , I want to prevent that the user submits the form by pressing the Enter key. I have tried the following, but didn't work. <button type="submit" @onkeypress:preventDefault>Save</button> Many thanks! 回答1: I have got this working by just putting 2 submit button's in the EditForm , with the first one disabled. <button type="submit" disabled style="display: none" aria-hidden="true"></button> <button type="submit">Save</button> 回答2: Here's a working code sample, run it and see

Why my Authentication State Provider not work?

血红的双手。 提交于 2020-07-09 14:34:26
问题 I use blazor with server side render and I want to do my own AuthenticationStateProvider, but it's not work and I do not know why. My ovveride method in public class LocalAuthenticationStateProvider : AuthenticationStateProvider : public async override Task<AuthenticationState> GetAuthenticationStateAsync() { if (await _storageService.ContainKeyAsync("User")) { var userInfo = await _storageService.GetItemAsync<LocalUserInfo>("User"); var claims = new[] { new Claim("Email", userInfo.Email),

Best way to share data between two child components in Blazor

泄露秘密 提交于 2020-07-09 12:07:17
问题 I have this code. <ParentComponent> <ChildComponet> @renderFragment </ChildComponent> <ChildComponetn> <GridComponent Data="@dataList"/> </ChildComponent> </ParentComponent> where @renderFragment is dynamically render componet and Grid componet is list of some data with actions like "add new", "edit record", "delete". If we click "add new", form for add new record is opened dynamically in @renderFragment and we want to refresh grid data after submit form but we don't know how to share some

Blazor: Adding a custom AuthenticationStateProvider in Startup.cs not recognized

孤人 提交于 2020-07-08 12:49:15
问题 I am trying to implement a login using a custom database. As far as I can tell, I need to override AuthenticationStateProvider in order to accomplish this. In MyServerAuthenticationStateProvider.cs: public class MyServerAuthenticationStateProvider : AuthenticationStateProvider { string UserId; string Password; public void LoadUser(string _UserId, string _Password) { UserId = _UserId; Password = _Password; } public override async Task<AuthenticationState> GetAuthenticationStateAsync() { var

CSS from Blazor Component Lib not loaded

江枫思渺然 提交于 2020-07-06 19:59:57
问题 I want to use my customs CSS located on the wwwroot/css/. in my BlazorControllers/Components/. files but nothing is loaded at execution. Is there something to specify in the client or in the lib project settings ? My Library project is BlazorControllers and I use the component of the library in the Client project 回答1: In your Index.html (or _Host.cshtml) file, below the site.css line, add <link href="_content/<YourLibrary>/styles.css" rel="stylesheet" /> where <YourLibrary> seems to be

How to fix “The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time” error

风流意气都作罢 提交于 2020-07-04 10:06:15
问题 I've already enabled CORS on the project in C# .net Core In startup.cs I've added lines ... services.AddCors(); ... app.UseCors(builder => builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); But when I try to use API in another Blazor project I see in logs in my API project on Host this error The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time. Configure the policy by listing individual origins if credentials

How to fix “The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time” error

白昼怎懂夜的黑 提交于 2020-07-04 10:06:07
问题 I've already enabled CORS on the project in C# .net Core In startup.cs I've added lines ... services.AddCors(); ... app.UseCors(builder => builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); But when I try to use API in another Blazor project I see in logs in my API project on Host this error The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time. Configure the policy by listing individual origins if credentials

Customizing the AuthenticationStateProvider in Blazor Server App with Jwt Token Authentication

做~自己de王妃 提交于 2020-07-02 03:05:39
问题 I've noticed that many developers subclass the AuthenticationStateProvider both in Blazor Server App and Blazor WebAssembly App wrongly, and more imprtantly for the wrong reasons. How to do it correctly and when ? 回答1: First off, you do not subclass the AuthenticationStateProvider for the sole purpose of adding claims to the ClaimPrincipal object. Generally speaking, claims are added after a user has been authenticated, and if you need to inspect those claims and tranform them, it should be

Customizing the AuthenticationStateProvider in Blazor Server App with Jwt Token Authentication

假装没事ソ 提交于 2020-07-02 03:05:38
问题 I've noticed that many developers subclass the AuthenticationStateProvider both in Blazor Server App and Blazor WebAssembly App wrongly, and more imprtantly for the wrong reasons. How to do it correctly and when ? 回答1: First off, you do not subclass the AuthenticationStateProvider for the sole purpose of adding claims to the ClaimPrincipal object. Generally speaking, claims are added after a user has been authenticated, and if you need to inspect those claims and tranform them, it should be