Short question: Why does safari cause errors on my MVC3 web application - Request.Form is blank for some reason?
Detailed question: My MVC3 website sends me an email every time there is an uncaught exception. I use these to find and fix bugs quickly, the email contains the exception, stack trace, user's IP address, user-agent string, and any form values that may have been posted.
Recently I have been noticing errors that have proven hard to track down, I thought I would post my findings here in the hope they help others.
The original symptom was these errors: System.Web.Mvc.HttpAntiForgeryException: A required anti-forgery token was not supplied or was invalid.
My form's action was throwing the error, and I couldn't figure out how anyone was getting the page into a state where it didn't have the __RequestVerificationToken hidden field, or the other form fields.
So I spent ages looking into cookies, and how the token works, and eventually just removed the [ValidateAntiForgeryToken] attribute on my ActionResult to see how it went - I still got errors though.
Then I noticed that the useragent strings showed it was only Safari 5.1.7 causing the issue.