验证视图状态MAC失败。如果此应用程序由Web场或群集托管,请确保配置指定相同的validationKey和验证算法。 AutoGenerate不能...... [英] Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot...

查看:173
本文介绍了验证视图状态MAC失败。如果此应用程序由Web场或群集托管,请确保配置指定相同的validationKey和验证算法。 AutoGenerate不能......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅下面给出的设计代码



see the design code given below

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="testpage.aspx.vb" Inherits="testpage" 

EnableViewStateMac="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
<title>Untitled Page</title>

<script type="text/javascript">

function callme(frmname)
{
var myForm = document.forms[frmname];
myForm.submit();
}

</script>

</head>
<body>
<form id="frm1" method="post" style='margin-top: 0px; margin-bottom: -10px'  runat="server"

action="Default.aspx">
<div id="button2" style="float: left;" önclick="callme('frm1');">
<a style="removed: pointer" class="smallfnt3">Register Now</a>
</div>

</form>
</body>
</html>





它显示错误为



验证视图状态MAC失败。如果此应用程序由Web场或群集托管,请确保< machinekey> configuration指定相同的validationKey和验证算法。 AutoGenerate不能在群集中使用。



请帮助。



it shows error as

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machinekey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

Please Help.

推荐答案

这可能是因为表单标记中的'操作'属性。如果您在forms元素上指定了一个操作,并且该操作与您要浏览的页面不同,则会发生此错误。之前,action属性被忽略了。如果要启用viewstate,请删除action属性,或将其更改为发布到右侧页面。



详细信息:安装.NET 3.5 SP1后,viewstate MAC验证失败 [ ^ ]
This can be because of the 'action' attribute in your form tag. This error happen if you have specified an action on the forms element, and if the action is different than the page you are browsing to. Earlier, the action attribute was ignored. Remove the action attribute, or change it to post to the right page if you want to have viewstate enabled.

Details here: Validation of viewstate MAC failed after installing .NET 3.5 SP1[^]


如何修复视图状态MAC验证失败。如果此应用程序由Web场或群集托管,请确保配置指定相同的validationKey和验证算法。 AutoGenerate不能在群集中使用





我们正在测试将网站部署到2个负载均衡的IIS 7上服务器前几天,网站正在加载正常。第二天早上,有一位测试人员在网站上报告了一个erorr,他说:     viewstate MAC验证失败。如果此应用程序由Web场或群集托管,请确保< machinekey> configuration指定相同的validationKey和验证算法。 AutoGenerate无法在群集中使用 。 我们查看了错误并意识到我们需要创建一个静态机器密钥并将其添加到我们的IIS7 Web服务器的web.config中以解决此问题。



在web.config中添加以下代码。

How to fix "Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster"


We were testing the deployment of a website onto 2 load balanced IIS 7 servers the other day, and the sites were loading fine. the next morning one of the testers was reporting an erorr on the website that said     "Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machinekey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster" . We looked at the error and realised that we need to create a static machinekey and add it into the web.config of both our IIS7 web servers to fix the issue.

Add following code in web.config.
<machinekey validationkey="AutoGenerate,IsolateApps" decryptionkey="AutoGenerate,IsolateApps" validation="SHA1" decryption="Auto" />


如果删除你发布的表格runat服务器属性它会工作正常



if you remove your posted form runat server attribute it will work fine

<form id="frm1" method="post" style="margin-top: 0px; margin-bottom: -10px" runat="server">
action="Default.aspx"></form>





赞这样





like this

<form id="frm1" method="post" style="margin-top: 0px; margin-bottom: -10px">
action="Default.aspx"></form>


这篇关于验证视图状态MAC失败。如果此应用程序由Web场或群集托管,请确保配置指定相同的validationKey和验证算法。 AutoGenerate不能......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆