An error occurred while verifying the view status Mac. solution:

Source: Internet
Author: User
Tags stack trace
Error Message

When debugging a page with Cookie form submission today, the browser reports an error message: An error occurred while verifying the view status Mac. If this application is hosted by a network farm or cluster, make sure that the <machinekey> Configuration specifies the same validationkey and verification algorithm. Autogenerate cannot be used in a group.

Note: An unhandled exception occurs during the execution of the current Web request. Check the stack trace information for details about the error and the source of the error in the code. Exception details: system. Web. httpexception: failed to verify view status Mac. If this application is hosted by a network farm or cluster, make sure that the <machinekey> Configuration specifies the same validationkey and verification algorithm. Cannot be used in a group
Autogenerate.

Possible causes


If a cluster is used, multiple Web servers provide the same service. Since the page may initiate an initial request on one machine, and PostBack sends the request to another machine, their machinekey is different, and an error occurs. This can be solved by manually setting the Machine Key of all servers to the same key. Each machine has a randomly generated machine key, which is used for encryption and verification by viewstate. If the viewstate is not encrypted with the machine key of this machine, an error occurs.

ASP. NET runat = 'server' encrypts viewstat on Mac

Solution

I checked a lot of information on the Internet. The following are the solutions I found:

Method 1: Remove runat = "server ".

This method is the most ineffective method, because the Asp.net control is a server control, so you have to place it in a form with runat = "server". This solution fails to solve the problem.

Method 2: Add enableeventvalidation = "false" enableviewstatemac = "false" or add <pages enableeventvalidation = "false" enableviewstatemac = "false"/> to webconfig.

<system.web>    <pages enableEventValidation="false" viewStateEncryptionMode ="Never" /></system.web 


The optional Boolean attribute of enableviewstate. The default value is true. Specifies whether the view status is enabled and maintained between multiple page requests.

The optional Boolean attribute of enableviewstatemac. The default value is true. Specifies whether ASP. NET should run the message authentication code (MAC) on The View status of the page when the page is sent back from the client ). If the value is true, check the encrypted view status to verify that the view status has been tampered with on the client.

Viewstateencryptionmode: the Optional viewstateencryptionmode attribute. The default value is auto. This attribute is a new attribute in. netframework 2.0.
The always view status is always encrypted.
The never view State is never encrypted, even when the control requests encryption.
The auto view status is encrypted based on the request of the control.

The purpose of this method is not to add viewstate to the receiving page, that is, authentication code (MAC) is not performed on The View status of the page. Therefore, this method is also a non-security method.

Method 3: Add the following content to webconfig: <machinekey validation = "3DES" validationkey = "encrypt" decryption = "3DES" decryptionkey = "encrypt"/>

<system.web>    <machineKey validation="3DES" validationKey="319B474B1D2B7A87C996B280450BB36506A95AEDF9B51211" decryptionKey="280450BB36319B474C996B506A95AEDF9B51211B1D2B7A87" decryption="3DES"/></system.web > 


This method is to manually specify the Authentication Encryption information, so this method is a security method. We recommend that you use this method.

Summary

There are still many methods such as setting <% @ page DEBUG = "ture" %> and other solutions that do not work. However, you can try to solve different problems. Solution 2 and solution 3 are effective methods to solve this problem. However, solution 3 is recommended because solution 2 is a bit insecure.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.