An error occurred while verifying the view status Mac. If this application is hosted by a network farm or group...

Source: Internet
Author: User
Tags stack trace
This problem has plagued me for a long time and finally solved it. If you get the answer here, please have dinner! "/" Indicates a server error in the application.

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 error occurred while executing 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: 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.

Source error:

[No relevant source line]

Source file:C: \ windows \ Microsoft. NET \ framework \ v2.0.50727 \ temporary ASP. Net files \ Root \ f8067725 \ e4ea7afb \ app_web_ny2ucv3x.6.csRow:0

Stack trace:

[Httpexception (0x80004005): data cannot be verified.] System. web. configuration. machinekeysection. getdecodeddata (byte [] Buf, byte [] modifier, int32 start, int32 length, int32 & datalength) + 2549660 system. web. UI. objectstateformatter. deserialize (string inputstring) + 214 [viewstateexception: The view status is invalid. Client IP: 60.212.12.99 port: 2017 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; sv1) viewstate:/login Bytes/second Failed...] [httpexception (0x80004005): 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.] System. web. UI. viewstateexception. throwerror (exception inner, string persistedstate, string errorpagemessage, Boolean macvalidationerror) + 116 system. web. UI. objectstateformatter. deserialize (string inputstring) + 251 system. web. UI. objectstateformatter. system. web. UI. istateformatter. deserialize (string serializedstate) + 4 system. web. UI. util. deserializewithassert (istateformatter formatter, string serializedstate) + 37 system. web. UI. hiddenfieldpagestatepersister. load () + 220 system. web. UI. page. loadpagestatefrompersistencemedium () + 83 system. web. UI. page. loadallstate () + 35 system. web. UI. page. processrequestmain (Boolean includestagesbeforeasyncpoint, Boolean includestagesafterasyncpoint) + 6953 system. web. UI. page. processrequest (Boolean includestagesbeforeasyncpoint, Boolean includestagesafterasyncpoint) + 154 system. web. UI. page. processrequest () + 86 system. web. UI. page. processrequestwithnoassert (httpcontext context) + 18 system. web. UI. page. processrequest (httpcontext context) + 49 ASP. webapp_admin_affiche_gridviewshowdata_aspx.processrequest (httpcontext context) in c: \ windows \ Microsoft. net \ framework \ v2.0.50727 \ temporary ASP. net files \ Root \ f8067725 \ e4ea7afb \ app_web_ny2ucv3x.6.cs: 0 system. web. callhandlerexecutionstep. system. web. httpapplication. iexecutionstep. execute () + 154 system. web. httpapplication. executestep (iexecutionstep step, Boolean & completedsynchronously) + 64

 

 

 

Version:Microsoft. NET Framework Version: 2.0.50727.42; ASP. NET version

If you encounter this error when executing your ASP. NET program:"Verify view statusMacFailed. If this application is hosted by a network farm or cluster, make sure that<Machinekey>The sameValidationkeyAnd verification algorithms. Cannot be used in a groupAutogenerate."So it means that you didn't allow your application to use the unified machinekey. What is the role of the machinekey? According to the msdn standard, "The key is configured to encrypt and decrypt Forms authentication cookie data and view status data, it is used to verify the non-process session status identity." That is to say, many ASP. NET encryption relies on values in machinekey, such as Forms authentication cookie and viewstate encryption. By default, Asp. net configuration is dynamically generated by yourself. If a single server is okay, but if multiple servers are load balanced, machinekey is also dynamically generated. The machinekey values on each server are inconsistent, as a result, the encrypted results are inconsistent and the verification and viewstate cannot be shared. Therefore, you must configure the same machinekey for Server Load balancer instances on each site.

Algorithm generated by machinekey:

Validationkey = createkey (20 );

Decryptionkey = createkey (24 );

Protected string createkey (INT Len)

{

Byte [] bytes = new byte [Len];

New rngcryptoserviceprovider (). getbytes (bytes );

Stringbuilder sb = new stringbuilder ();

For (INT I = 0; I <bytes. length; I ++)

{

SB. append (string. Format ("{0: X2}", bytes [I]);

}

Return sb. tostring ();

}

See matchinekey configuration for reference:

<? XML version = "1.0"?>

<Configuration>

<System. Web>

<Machinekey validationkey = "3ff1e929bc0534950b0920a7b59fa698bd02dfe8" decryptionkey = "encrypt" decryption = "3DES" validation = "sha1"/>

</System. Web>

</Configuration>

If the gridview is used and the datakeynames attribute is specified, it is for security reasons (because the field specified by datakeynames represents the primary key of the data, and the primary key value needs to be saved in the view State and sent to the client, if you tamper with the primary key value, it will cause security issues), the gridview will require the encrypted view status. Therefore, a <input type = "hidden" name = "_ viewstateencrypted" id = "_ viewstateencrypted" value = ""/>. However, the updatepanel of Atlas must be placed inside <form> </form>, that is, before </form>.

<Pages validaterequest = "false"/>:

<Pages enableeventvalidation = "false" viewstateencryptionmode = "never"/>

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.