asp.net virtual host often appear Mac authentication Failure error Solution _ Practical Skills

Source: Internet
Author: User
Tags sha1 stack trace
Error occurred:
Server error in '/' Application.
--------------------------------------------------------------------------------

Verify view state MAC failed. If this application is hosted by a network farm or cluster, make sure that the <machineKey> configuration specifies the same validationkey and authentication algorithm. AutoGenerate cannot be used in a cluster.

Note: An unhandled exception occurred during the execution of the current WEB request. Check the stack trace for more information about the error and where the error occurred in the code.

Exception Details: System.Web.HttpException: Verify view state MAC failed. If this application is hosted by a network farm or cluster, make sure that the <machineKey> configuration specifies the same validationkey and authentication algorithm. AutoGenerate cannot be used in a cluster.

SOURCE Error:


只有在调试模式下进行编译时,生成此未处理异常的源代码才会显示出来。若要启用此功能,请执行以下步骤之一,然后请求 URL:

1. 在产生错误的文件的顶部添加一条“Debug=true”指令。例如:

  <%@ Page Language="C#" Debug="true" %>

或:

2. 将以下的节添加到应用程序的配置文件中:

<configuration>
   <system.web>
       <compilation debug="true"/>
   </system.web>
</configuration>

请注意,第二个步骤将使给定应用程序中的所有文件在调试模式下进行编译;第一个步骤仅使该特定文件在调试模式下进行编译。

重要事项: 以调试模式运行应用程序一定会产生内存/性能系统开销。在部署到生产方案之前,应确保应用程序调试已禁用。

Workaround: because. NET in the transfer process between the client data and the server, it is necessary to encrypt and decrypt the data. and encryption and decryption algorithm can be configured in the web.config, in Web.config, validationkey and decryptionkey defaults are autogenerate, the system randomly generated keys, if the local or using a stand-alone host is usually not a problem, but Is using a virtual host, the problem occurs when multiple virtual hosts exist on a single server, and it is also noted in MSDN that you cannot use AutoGenerate in a cluster to specify a fixed key value. This requires adding a configuration item about machinekey in the Web.config and manually setting the key value therein, note that the different encryption algorithms are different for the maximum length of the key, where the AES,DES,3DES,SHA1,MD5 can be used, and I only know that DES's key character length is 16,3des length is 48, the key length must be equal to its maximum length when manually set, otherwise there will be an error! The 16 value of the key can be entered randomly.

The specific method of operation is as follows:

Locate the Web.config file in the root directory where the Web site runs, and add the corresponding items as shown in the following figure Galiang. When setting, modify the key value yourself, which is related to the encryption security of the server. The picture does not see clearly, please click the picture to view.

Code:<machinekey validation= "SHA1" validationkey= " 78ea3850338fbadce59d8ddf58c9e4518e7510149c46142d7aad7f1ad49d95d4 "decryptionkey=" 5FC88DFC24AE12BC "/>

Related Article

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.