Server Error when saving page in edit mode

May 7, 2010 at 1:48 PM

Hi, Webhost4life.com just migrated my site using version 1.3 to their new platform.  When in edit mode I click save, I randomly get the following error:

Server Error in '/cwv1v4' Application.
--------------------------------------------------------------------------------

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.
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: 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.

Source Error:


[No relevant source lines]


Source File: c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\cwv1v4\a78a509d\1c84bd6\App_Web_2w7tdss9.4.cs Line: 0

Stack Trace:


[HttpException (0x80004005): Unable to validate data.]
System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +289
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +140

[ViewStateException: Invalid viewstate.
Client IP: 96.250.158.4
Port: 50400
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 3.5.21022; Media Center PC 5.0; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; SLCC1)
ViewState: /wEPDwUKMTU1NDc3NTc0NA9kFgJmD2QWAgIDD2QWAgIBEGRkFgQCAQ9kFgJmD2QWAgIBDzwrAA0CAA8WAh4LXyFEYXRhQm91bmRnZAwUKwANBTEwOjAsMDoxLDA6MiwwOjMsMDo0LDA6NSwwOjYsMDo3LDA6OCwwOjksMDoxMCwwOjExFCsAAhYOHgRUZXh0BQ5BZG1pbmlzdHJhdGlvbh4FVmFsdWUFDkFkbWluaXN0cmF0aW9uHgtOYXZpZ2F0ZVVybAUjL2N3djF2NC9hZG1pbmlzdHJhdGlvbi9kZWZhdWx0LmFzcHgeB0VuYWJsZWRnHgpTZWxlY3RhYmxlZx4IRGF0YVBhdGgFIy9jd3YxdjQvYWRtaW5pc3RyYXRpb24vZGVmYXVsdC5hc3B4HglEYXRhQm91bmRnFCsABgUTMDowLDA6MSwwOjIsMDozLDA6NBQrAAIWDh8BBQlDTVMgU2V0dXAfAgUJQ01TIFNldHVwHwMFIy9jd3YxdjQvYWRtaW5pc3RyYXRpb24vd2Vic2l0ZS5hc3B4HwRnHwVnHwYFIy9jd3YxdjQvYWRtaW5pc3RyYXRpb24vd2Vic2l0ZS5hc3B4HwdnZBQrAAIWDh8BBRhTZWN0aW9ucy9QYWdlIEFzc2lnbm1lbnQfAgUYU2VjdGlvbnMvUGFnZSBBc3NpZ25tZW50HwMFJC9jd3Y...]

[HttpException (0x80004005): 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.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +106
System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) +14
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +242
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +207
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +105
System.Web.UI.Page.LoadAllState() +43
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
System.Web.UI.Page.ProcessRequest() +80
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.default_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\cwv1v4\a78a509d\1c84bd6\App_Web_2w7tdss9.4.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4016; ASP.NET Version:2.0.50727.4016

does anyone have a clue as to what is causing this error and how to correct it?

May 7, 2010 at 2:17 PM

WebHost4Life.com just advised me that they are now using clustering and my code will need to be revised.  can anyone advise where and what needs to be modified to prevent this error?

May 12, 2010 at 3:45 AM

Webhost4Life advised me that using a machinekey generator and adding the following lines of code to the <system.web> section of the web.config file

 corrected the problem:


  <machineKey
validationKey="3F7BFCC3A18B3DF56D6075C86FC9BD4F9F6AA06682505E9923B337BC94A14510BAA167614EB3AE8171E3C26D42C57CD25DAE64F0686C173FDD3C18A149DEAB65"
decryptionKey="6405E71E0FA2E399808E9D85E2921ED5DD21CE86CFF952701FC8D9500448BC0F"
validation="SHA1" decryption="AES"
/>
    <pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" />