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?

  • ABP Framework version: v7.2.2
  • UI Type: MVC
  • Database System: EF Core
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I am trying to call one of our API endpoints using navigator.sendBeacon and it always throws a 400 error. This same end point works if I do it as an AJAX call instead. Can you please advise what may be needed to configure this to work properly?

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
  • ABP Framework version: v7.2.1
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I'm using the abp-modal with a razor page and the form posts to a handler in the razor page. If there are server side validation errors, the modal still closes and never shows the validation errors. When you access the page directly, not through the modal, it behaves as expected showing the server side validation messages. Please advise on what is necessary for server side validation errors to display in the normal way inside an abp-modal.

Perfect! Thanks again for your help!

Showing 1 to 10 of 22 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11