Summary of Solutions to Mac failures in view status validation (from: http://hi.baidu.com/motiansen/blog/item/2c10d5031bc9b67b3912bbb5.html)

Source: Internet
Author: User

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.

I have encountered this problem inexplicably. Below I have summarized some common solutions that can basically solve the problems encountered in Asp.net programming. However, Microsoft is partly responsible for Mac failure in view status verification. I had a good program and this problem suddenly occurred during a period of time. Do you feel the same way.

Method 1:

An error occurred while verifying the view status Mac.
You can add two attributes to <page...> on the current page:
Enableeventvalidation = "false" viewstateencryptionmode = "never"

Of course, you can also add the following in Web. config:
<Pages enableeventvalidation = "false" viewstateencryptionmode = "never"/>

Method 2:

Error prompt:

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

Solution:

The runat = 'server' of Asp.net encrypts viewstat on Mac, so that only the same page can be submitted when submitting data. Add

@ Page enableviewstatemac = "false"

You can receive the data returned from the post on another page.

Method 3:

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.

If you use the Web garden, you need to set the same machinekey in the web. config of each server.

Web. config example:

<? XML version = "1.0" encoding = "gb2312"?>
<Configuration>
<Configsections>
<Section name = "rewriterconfig" type = "urlrewriter. config. rewriterconfigserializersectionhandler, urlrewriter"/>
</Configsections>

<Rewriterconfig>
<Rules>
<Rewriterrule>
<Lookfor> ~ /C (/d {1, 8})/. aspx </lookfor>
<Sendto> ~ /List. aspx? Cid = $1 </sendto>
</Rewriterrule>
<Rewriterrule>
<Lookfor> ~ /C (/d {}) P (/d {})/. aspx </lookfor>
<Sendto> ~ /List. aspx? Cid = $1 & amp; page = $2 </sendto>
</Rewriterrule>
<Rewriterrule>
<Lookfor> ~ /N (/d {}) C (/d {})/. aspx </lookfor>
<Sendto> ~ /Show. aspx? Id = $1 & amp; cid = $2 </sendto>
</Rewriterrule>
<Rewriterrule>
<Lookfor> ~ /N (/d {}) C (/d {}) P (/d {})/. aspx </lookfor>
<Sendto> ~ /Show. aspx? Id = $1 & amp; cid = $2 & amp; page = $3 </sendto>
</Rewriterrule>
</Rules>
</Rewriterconfig>

<Deleetask>
<Add key = "charset" value = "gb2312"/>
<Add key = "mdbpath" value = "DB/iwms. cs"/>
<! -- "&", "<", ">" Cannot appear in SQL connection strings. If you must use "& amp;", "& lt", "& gt; "Replace -->
<Add key = "sqlconnstring" value = "Server = (local); uid = sa; Pwd =; database = dvnews"/>
</Appsettings>

<System. Web>

<Compilation defaultlanguage = "C #" DEBUG = "false"/>

<! -- If it is. Net SDK 1.0 or a previous version, delete validaterequest = "false" -->
<Pages validaterequest = "false" enablesessionstate = "true" enableviewstate = "true"/>

<Customerrors mode = "off"/>

<Globalization fileencoding = "gb2312" requestencoding = "gb2312" responseencoding = "gb2312" Culture = "ZH-CN"/>

<Httpruntime maxrequestlength = "2048"/>

<Httpmodules>
<Add type = "urlrewriter. modulerewriter, urlrewriter" name = "modulerewriter"/>
</Httpmodules>

<Httphandlers>
<Add verb = "*" Path = "*. aspx" type = "urlrewriter. rewriterfactoryhandler, urlrewriter"/>
<Add verb = "post, get" Path = "ajaxpro/*. ashx" type = "ajaxpro. ajaxhandlerfactory, ajaxpro"/>
</Httphandlers>

</System. Web>

</Configuration>

Method 4:

Validationkey in <machinekey> in Web. config. Please read the error message carefully. This section needs to be added by yourself.
Http://msdn.microsoft.com/zh-cn/library/w8h3skw9 (vs.80). aspx

 

Method 5:

"/" 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: 

 

 

 

 

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>

We believe that the above five steps can solve the "verify view status Mac failure" problem. 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. "This depressing problem!

 

[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

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.