أنشطة "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.

عرض 1 الي 10 من 15 إدخالات
Made with ❤️ on ABP v8.2.0-preview Updated on مارس 25, 2024, 15:11