验证视图状态MAC失败 [英] Validation of view state MAC failed

查看:60
本文介绍了验证视图状态MAC失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请勿将此帖子标记为重复..由于我是 asp.net 的新手,请帮助我解决问题,我在理解方面有些困难.

Please don't mark this post as duplicated.. Please help me to fix my issue since I am very new to asp.net I have some difficulties with understanding.

我正在研究 VS 2010 ,并尝试熟悉 asp.net网站..我有两个网页,分别是 Default.aspx和Result.aspx.

I am working on VS 2010 and try to familiarize with asp.net web site. I have two web pages called Default.aspx and Result.aspx.

Default.aspx

<form id="Form1" runat="server" action="Result.aspx">  
    //Some Controllers (Dynamically added textboxes and submit button)
</form>  

一旦我填写了表格,当它提交时,就会出现以下错误.

Once I fill the form and when it is submit following error comes.

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

我尝试添加 EnableViewStateMac ="false" ,但是没有运气.

I tried to add EnableViewStateMac="false" but have no luck.

请建议我解决此问题,如果您能向我解释为什么会出现,请多加赞赏.

Please advice me to fix this and appreciate if you could explain me why this comes.

推荐答案

ASP.NET与Web开发中的其他语言有着完全不同的模型,旨在模仿Windows Forms开发范例.在其他语言中,通常会发布到另一个URL,而ASP.NET中的操作通常是通过发布回同一页面上的事件来完成的.您遇到的问题与将ViewState发布到另一个页面有关,请参阅

ASP.NET has a very different model to other languages in web development, designed to emulate the Windows Forms development paradigm. Whereas in other languages it is common to post to another URL, operations in ASP.NET are usually accomplished by posting back to events on the same page. The issue you are experiencing is related to the fact you are posting ViewState to another page, see http://blogs.msdn.com/b/tess/archive/2009/04/14/validation-of-viewstate-mac-failed-after-installing-net-3-5-sp1.aspx.

顺便说一句,您不应该在生产服务器上设置EnableViewStateMac = false",它是一种防止用户篡改保存在viewstate中的数据的机制,将其关闭会删除此保护-仅处理问题的症状,而不是原因.

As an aside, you shouldn't set EnableViewStateMac=false" on a production server, it is a mechanism to prevent tampering of the data held in viewstate by the user, switching it off removes this protection - and only deals with a symptom of the problem, not the cause.

在这种情况下,我不认为这是问题所在,但由于出现此错误,因此始终值得检查的是,在将数据存储在会话中之前,没有将ViewStateUserKey设置为会话ID(ASP.NET不会跟踪会话ID中不包含数据的会话ID.

I don't think this is the issue in this case, but with this error it's always worth checking that you're not setting the ViewStateUserKey to the Session ID before you have stored data in the session (ASP.NET will not track Session IDs where the session does not contain data).

这篇关于验证视图状态MAC失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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