c# - viewstateexception - validation of viewstate mac failed.net 4

ViewState invalid only in Safari (3)

I've been doing a little research into this and whilst I'm not entirely sure its the cause I believe it is because Safari is not returning the full result set (hence cropping it).

I have been in dicussion with another developer and found the following post on Channel 9 as well which recommends making use of the SQL State service to store the viewstate avoiding the postback issue and also page size.


Does this seem like the best solution?

One of the sites I maintain relies heavily on use of ViewState (it isn't my code). However, on certain pages where the ViewState is extra-bloated, Safari throws a "Validation of viewstate MAC failed" error.

This appears to only happen in Safari. Firefox, IE and Opera all load successfully in the same scenario.

My first port of call would be to go through the elements on the page and see which controls:

  1. Will still work when I switch ViewState off
  2. Can be moved out of the page and into an AJAX call to be loaded when required

Failing that, and here's the disclaimer - I've never used this solution on a web-facing site - but in the past where I've wanted to eliminate massive ViewStates in limited-audience applications I have stored the ViewState in the Session.

It has worked for me because the hit to memory isn't significant for the number of users, but if you're running a fairly popular site I wouldn't recommend this approach. However, if the Session solution works for Safari you could always detect the user agent and fudge appropriately.

Postback is not working in Safari in Windows 7

Safari has an issue when working with Windows Authentication under IIS if Negotiate provider is enabled so AJAX POST is not working.

How to resolve?
In IIS, go to the Authentication settings of your website. Right click on Windows Authentication, choose providers and remove Negotiate, leaving NTLM this makes everything works fine.

AJAX POST Request Only Works Once in Safari 5
Negotiate Mechanism article in Wikipedia shows that it is not implemented in Safari