400 error after I sort and then click on a column that calls a Post handler in razor pages
400 error after I sort and then click on a column that calls a Post handler in razor pages
dsand
Posts: 18Questions: 5Answers: 1
Can you please help me. I have posted the issue on Stack Oveflow. The datagrid retrieves data fine and when I click on the first column it calls the handler and redirects to another page. But when I click on sort for the column and then click on the value in the column, it does not find the handler method and gives me a 400 error.
This question has an accepted answers - jump to answer
Answers
The 400 bad request error is being returned by the server. You will need to look at the server logs to find out why its returning this error. There is no way to tell by looking at the client side code.
Kevin
Looking closer at your config you are using jQuery ajax() to fetch the data. Datatables is not sending an ajax request or any other redirection.
Kevin
Sorry, here's my latest code. It calls a post handler and then I redirect it to another page in that handler.
I see there's a solution on SO, so glad all sorted,
Colin
HI Colin, It still does not work.
Did you look at the server logs to see why its returning the 400 error? Let us know what you find.
Kevin
This is what I found in the server logs
400 0 0 150
It does not say anything else. Could it be because I am not using the XSRF token properly?
Hmm. Maybe you need to enable more detailed logging for the web server you are using. The error can happen for any number of reasons. Here are some ideas:
https://kinsta.com/knowledgebase/400-bad-request/
Kevin
I figured it out. It was not including the antiforgery token when it sorts. So, I had to take it out of the init complete and put it in the draw event function