Sunday 14 October 2012

Handling Validation of Viewstate MAC failed Error



Handling Validation of Viewstate MAC failed Error


Step 1:

Include the following line in the webconfig under <system.web> :

<pages enableEventValidation="false" viewStateEncryptionMode="Never">

You can also include these things individually in every design page..

For example:

<%@ Page Language="C#" MasterPageFile="~/MasterHome.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" enableEventValidation="false" viewStateEncryptionMode="Never" Title="Untitled Page" %>


Step 2:

Now  Include the following code inside <system.web> :
 
<customErrors defaultRedirect="~/ErrorPage.htm" mode="On"/>

This  is included in order to handle the error generated by the website in any case.. We have to include a .htm file which gets displayed whenever there is any error in the website…

Step 3:
The last step is to include validation and decryption key in the machine key tag inside <system.web> :

This can done by generating these keys from the following website:


Add the generated keys in system.web section of the webconfig:

Example:
<system.web>
  <machineKey validationKey="AutoGenerate,IsolateApps"
    decryptionKey="AutoGenerate,IsolateApps"
    validation="SHA1"/>
</system.web>

Refer this for more details:

http://msdn.microsoft.com/en-us/library/ff649308.aspx

1 comment:

  1. Worked Perfectly well, no issues again, thanks a billion, you are the man

    ReplyDelete

Thank You for Your Comments. We will get back to you soon.

back to top