Starts in:
1 DAY
12 HRS
21 MIN
57 SEC
Starts in:
1 D
12 H
21 M
57 S

Activities of "trina.thompson"

I was able to solve this by disabling AbpAutoValidateAntiforgeryTokenAuthorizationFilter for the controller that we need to call with navigator.sendBeacon. We set a custom AbpAntiForgeryOptions.AutoValidateFilter for this purpose.

Hello,

Thank you for your suggestion. I tried adding this to the API Endpoint [IgnoreAntiforgeryToken]. I also tried passing the token in the header in your example. Both still resulted in a 400 error.

Do you have any other suggestions?

Thank you for the idea. However, this does not provide our desired user experience. We would like the validation to be displayed to the user in the form as is the normal behavior for validation error feedback. Is there a way to achieve our desired behavior?

Code Behind:

public async Task<IActionResult> OnPostAsync()
{
    if (!ModelState.IsValid)
    {
        return Page();
    }
    try
    {
        await _blockedAccountAppService.CreateAsync(CreateBlockedAccount);
    }
    catch (AbpValidationException ex)
    {
        foreach (var error in ex.ValidationErrors)
        {
            ModelState.AddModelError($"CreateBlockedAccount.{error.MemberNames.FirstOrDefault()}", error.ErrorMessage);
        }
        return Page();
    }
    catch (BusinessException ex)
    {
        ModelState.AddModelError("", ex.Message);
        return Page();
    }
    return Page();
}

Modal:

<form method="post" action="@Url.Page("/platform-portal/Processing/ExceptionHandling/BlockedAccounts/Create")">
    @Html.AntiForgeryToken()
    Modal Content Here
</form>

Script:

let dataGrid;
let createBlockedAccountModal;

$(document).ready(function () {
    createBlockedAccountModal = new abp.ModalManager({
        viewUrl: '/platform-portal/Processing/ExceptionHandling/BlockedAccounts/Create'
    });
    createBlockedAccountModal.onResult(function (a, b) {
        dataGrid.refresh();
    });
});

$('#openAddBlockedAccountModal').click(function () {
    createBlockedAccountModal.open({
    });
});

Steps to reproduce:

  • Launch the modal
  • Enter invalid data
  • Hit save button
  • Modal closes and does not show server error

Perfect! Thanks again for your help!

Thank you, that worked for me. Is there something extra that I need to do to get the current value to show when the page initially shows? It always just shows as blank.

Thanks for the suggestion. Instead of creating a shared module, we decided to use the business exception code namespace to lookup the correct localization resource.

Showing 1 to 10 of 15 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06