ASP.NET Core Razor - AJAX Post - 400 Bad Request ASP.NET Core Razor - AJAX Post - 400 Bad Request ajax ajax

ASP.NET Core Razor - AJAX Post - 400 Bad Request


Just so there's no confusion in reading the revisions above and comment (which left me scratching my head for a minute), the solution is to change:

xhr.setRequestHeader("XSRF-TOKEN",

To:

xhr.setRequestHeader("RequestVerificationToken",

The answer is in the revision and the someone edited it out. It's also mentioned briefly in the comments. I'm certainly not taking any credit, just trying to minimize confusion for anyone else that encounters this insanity making error in the future.