A routing feature in ASP.NET Core for defining common URL prefixes that standardize and organize endpoint paths across controllers and APIs
A 400 Bad Request is expected here because of how the anti-forgery token is being passed.
By default, ASP.NET Core's antiforgery middleware rejects or ignores tokens in the query string. Tokens must be sent either inside the form body or via an HTTP header (such as RequestVerificationToken). Passing tokens in the URL is intentionally not supported out of the box because query strings are exposed in browser history, proxy logs, and server access logs.
Additionally, because your model uses [JsonPropertyName], you are likely sending a JSON payload via JavaScript (fetch or axios). In Razor Pages, you must add the [FromBody] attribute to the handler parameter to bind JSON:
public JsonResult OnPostOrder([FromBody] GoodsO[] g)
{
return new JsonResult(new { Status = true });
}
To give you an exact fix, could you share the JavaScript/client-side code you are using to send the request?
If you are using fetch, you typically need to send the token in the request headers instead:
fetch('?handler=Order', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'RequestVerificationToken': document.querySelector('input[name="__RequestVerificationToken"]').value
},
body: JSON.stringify(payload)
});