2010-11-20 81 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