- 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?
3 Answer(s)
-
0
Hi,
You may not be passing the CSRF token parameter
ABP will set it internally for Ajax https://github.com/abpframework/abp/blob/e57159f1b96a4937d75793874f9ed89d1c2131c4/npm/packs/jquery/src/abp.jquery.js#L255
-
0
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?
-
0
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.