I have an MVC2 application. I am trying to implement the AntiForgeryToken helper to prevent CSRF attacks.
I use this using Steve Sanderson's blog: http://blog.stevensanderson.com/2008/09/01/prevent-cross-site-request-forgery-csrf-using-aspnet-mvcs-antiforgerytoken-helper/
When I implement this in a new MVC2 project, it works. But the same code, when I put it in my REAL application, ALWAYS throws this exception: The required anti-fake token was not specified or was invalid.
Here is my controller code:
[ValidateAntiForgeryToken] public ActionResult SubmitUpdate() {
Code in view:
<% using (Html.BeginForm("SubmitUpdate", "Test")) {%> <%= Html.AntiForgeryToken() %> <input type="submit" value="Submit" /> <% } %>
There is no difference in the two applications, except that the real application uses ADFS for authentication. What am I missing? Any help would be greatly appreciated. Thanks!
source share