I got this error when I tried to call a OnClick in my form
Error: Failed validation of viewstate MAC. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same <machineKey> validationKey and validation algorithm. AutoGenerate can not be used in a cluster.
Code-Behind
<form runat="server" id="form1">
<asp:Button ID="btnImprimeBematech" runat="server" OnClick="btnImprimeBematech_OnClick" Text="Imprime Novo Bematech" />
</form>
I don’t understand becaus in others thread here in StackOverflow, some solutions was the action in the <Form> tag, but I don’t have any action in my form.
I tried put EnableViewStateMac="false" EnableSessionState="False" EnableViewState="false" in my <%@ Page but still the same error
The
machineKeyvalue has to be the same on all machines in a webfarm.Link : http://msdn2.microsoft.com/en-us/library/ms998288.aspx
You set this property on all pages not just one page
It is always advisable to go with specifying the custom key for encryption and decryption in web.config. This is because when you set the EnableViewStateMac value to false you expose your application to security threats. This is because validation of view state will not happen in this case.