2010-11-20 95 views
1

我使用这个模板:http://visualstudiogallery.msdn.microsoft.com/en-us/81153747-70d7-477b-b85a-0374e7edabef验证视图状态MAC失败

并得到以下错误:验证视图状态MAC失败.. Web场..

有很多人有这个问题和(?最好的)建议我发现了更新与计算机密钥的web.config(如该网站是在Web场):

<machineKey validation="SHA1" validationKey="" 
decryption="Auto" decryptionKey="" /> 

但现在我得到这个错误:

Unable to validate data. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Unable to validate data. 

Source Error: 

Line 6: <head> 
Line 7:  <title>Login</title> 
Line 8:  <%= Html.OpenIdSelectorStyles(this.Page) %> 
Line 9:  <link rel="stylesheet" type="text/css" href='<%= Url.Content("~/Content/loginpopup.css") %>' /> 
Line 10: </head> 


Source File: Line: 8 

Stack TraceWhy is this and how do I fix it? 

感谢 中号

回答

3

您的验证密钥的空间,将其删除。

您还需要小心,不要使用您在网上找到的机器密钥,因为它用作您的Cookie的加密密钥。使用网上发现的网站,尤其是在众所周知的网站上,可以更轻松地妥协网站。你可以在http://support.microsoft.com/kb/312906找到一些代码来生成密钥。

+0

是的,这工作非常好,但是当我使用你推荐的控制台应用程序,我得到这个错误:viewstate MAC验证失败。如果此应用程序由Web场或群集托管,请确保配置指定相同的验证密钥和验证算法。 AutoGenerate不能在群集中使用。 – Mikael 2010-11-20 18:11:27

+0

所以它工作时,我删除的空间,但它停止工作,当我尝试用我新生成的 – Mikael 2010-11-20 18:12:37

+3

替换密钥如果您更改机器密钥,任何旧的cookie将引发该错误,因为它不能被解密新的关键。尝试删除您的网站的Cookie并查看错误是否消失。 – tvanfosson 2010-11-20 18:13:39