Hi,
I am coding an ASP.NET MVC 2 application that does the following:
A view is loaded. Clicking on a button opens a jQuery UI Dialog that loads a partial view inside of it. (it loads a brand new instance everytime the dialog is opened using the "load" method of jQuery dialog).
This partial view has a form (AjaxForm) that gets posted to the server. I am using the anti-forgery token on this form and my ActionResult method has the ValidateAntiForgeryToken attribute.
Everything works fine on IE, Google Chrome and Safari but on Firefox (3.6) and Opera (10.61) the error below happens:
"System.Web.Mvc.HttpAntiForgeryException: A required anti-forgery token was not supplied or was invalid."
The weird (at least to me) part is that it happens ONLY the first time I try to post the form to the server. If I close my jQuery UI dialog and open it again (it will load a brand new instance of the partial view) then it works fine.
If I load the main view again and try to submit the partial view from the dialog I'll get the error the first time so it's not related on my opinion to a restart of the application that could cause the cookies to not be valid anymore.
I have checked on Firebug if there is any differences between the get and post for the scenarios where I get the error and the ones that succeeded but not differences were found.
Does anybody have any clues about it?
Thanks,
Cirilo