Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4291

EditForm.OnValidSubmit called 4 times in rapid succession

$
0
0

We have one user this is happening with. We cannot reproduce it and it is not happening to any others. And it has happened to them twice out of 8 uses of the relevant page. Needless to say, I can't create a MVE because we can't reproduce it.

The page (relevant parts) is:

@page "/Account/UserProfile"@attribute [Authorize]@inherits ExPageBase@implements IDisposable<EditForm EditContext="_editContext" OnValidSubmit="HandleValidSubmitAsync" OnInvalidSubmit="HandleInvalidSubmitAsync" Context="EditFormContext"><DataAnnotationsValidator /><CustomValidation @ref="_customValidation" /><DxFormLayout><DxFormLayoutItem ColSpanMd="12"><DxButton Text="Save Changes to Profile"                      Id="save"                      SubmitFormOnClick="true"                      Enabled="SubmitEnabled"                      RenderStyle="@ButtonRenderStyle.Primary" /></DxFormLayoutItem></DxFormLayout></EditForm>private async Task HandleValidSubmitAsync(EditContext editContext){    if (LoggerEx.IsEnabled(LogLevel.Debug))        LoggerEx.LogDebug($"User {User.Email} is updating their account.");    try    {        SubmitEnabled = false;        // ...    }    finally    {        SubmitEnabled = true;    }}

And the log shows:

Debug 16:09:12.139 [dw0sdwk00065I]-[user@mail.com] LouisHowe.web.Pages.Account.UserAccountProfile - User user@mail.com is updating their account.Debug 16:09:12.150 [dw0sdwk00065I]-[user@mail.com] LouisHowe.web.Pages.Account.UserAccountProfile - User user@mail.com is updating their account.Debug 16:09:12.160 [dw0sdwk00065I]-[user@mail.com] LouisHowe.web.Pages.Account.UserAccountProfile - User user@mail.com is updating their account.Debug 16:09:14.435 [dw0sdwk00065I]-[user@mail.com] LouisHowe.web.Pages.Account.UserAccountProfile - User user@mail.com is updating their account.

The user says they clicked submit once. We've tried everything we can to reproduce it with no luck.

When this happens it is causing an exception in the EntityFramework save of the data due to duplicates in collections of the user model object. This makes me think somehow the PageModel object is the same for all these calls, and that is then updating the underlying EF model object with the same collection items on each call, thereby placing duplicates in it.

How could the OnValidSubmit be called repeatedly in quick succession?

Update: MrC suggested it might be the DxButton. I looked at the html that generated and it's:

<button class="dxbl-btn dxbl-btn-primary dxbl-btn-standalone" id="save" type="submit"><span class="dxbl-btn-caption">Save Changes to Profile</span></button>

So I don't think DxButton is the issue.


Viewing all articles
Browse latest Browse all 4291

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>