How can I supply an AntiForgeryToken when posting JSON data using $.ajax?
I am using the code as below of this post: First I will fill an array variable with the correct values for the controller action. Using the code below I think it should be very straightforward by just adding the following line to the JavaScript code: data["__RequestVerificationToken"] = $('[name=__RequestVerificationToken]').val(); The <%= Html.AntiForgeryToken() %> is at its right place, and the action has a [ValidateAntiForgeryToken] But my controller action keeps saying: "Invalid forgery token" What am I doing wrong here? Code data["fiscalyear"] = fiscalyear; data["subgeography"] = $(list)