When does Ajax result in a bad request?

When does Ajax result in a bad request?

That means when an HTTP Post action method is called (normal or ajax), the framework will check the submitted request data and if it does not find a valid anti forgery token ( RequestVerificationToken header), it will be considered a bad request and a 400 response will be sent back.

How to fix ASPnet core Ajax request stack?

To fix this problem, you can explicitly read the value of __RequestVerificationToken hidden input (generated by the form tag helper) and send that in your ajax request headers.

How to create Ajax post in ASPnet core?

Try to specify the header with X-XSRF-TOKEN. For ABP Intercept XMLHttpRequest. In Core — make sure your tag includes method=”post”. The method is required to invoke the form tag helper which automatically adds the antiforgery token to the form. (I accidentally left off the method and didn’t notice because I was ajax-posting it.)

Why do I get a 400 response on Ajax?

I had thought the syntax was correct on both of these however every time I make the ajax call I get a 400 response. What is it that I am doing wrong? You are sending a completely broken and invalid JSON string to the server. It’s normal that the controller action rejects it.

What is WordPress admin-ajax.php Bad Request?

I have a strange and frustrating behaviour of wordpress admin-ajax.php file, when i make an ajax request it returns 400 error bad request.

Is it normal to reject a JSON request?

You are sending a completely broken and invalid JSON string to the server. It’s normal that the controller action rejects it. In addition to that you have put into comments the contentType parameter specifying that you want to send a JSON request.

Why do I get 400 error in jQuery Ajax?

Plus you need to add content type and datatype as well. If not you will encounter 415 error which says Unsupported Media Type. Try this.