By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,155 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

ViewState exception when submitting a page in Safari

P: 2
I get an error when submitting an .ASPX page in Safari beta, MAC and PC

document.getElementbyId(‘FolderBrowser’).submit();

After the server side code has executed without problems I get the following error.

Server Error in '/FileWayTest' 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:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[HttpException (0x80004005): Unable to validate data.]
System.Web.Configuration.MachineKeySection.GetDeco dedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +2546748
System.Web.UI.ObjectStateFormatter.Deserialize(Str ing inputString) +214

[ViewStateException: Invalid viewstate.
Client IP: 192.0.0.80
Port: 4057
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/522.15.5 (KHTML, like Gecko) Version/3.0.3 Safari/522.15.5
ViewState: /wEPDwUIOTA5OTg1MThkZB0TdeU3bnOlPBB5jBLNh4FsKeD+
Referer: http://192.0.0.13/filewaytest/folderbrowser.aspx?
Path: /filewaytest/folderbrowser.aspx]

[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(Except ion inner, String persistedState, String errorPageMessage, Boolean macValidationError) +116
System.Web.UI.ObjectStateFormatter.Deserialize(Str ing inputString) +251
System.Web.UI.ObjectStateFormatter.System.Web.UI.I StateFormatter.Deserialize(String serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFor matter formatter, String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +220
System.Web.UI.Page.LoadPageStateFromPersistenceMed ium() +83
System.Web.UI.Page.LoadAllState() +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6953
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +154
System.Web.UI.Page.ProcessRequest() +86
System.Web.Util.AspCompatApplicationStep.System.We b.HttpApplication.IExecutionStep.Execute() +19
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +64

This application is not hosted by a web farm or cluster. I can get rid of this error by setting the enableViewStateMac=false, however this causes other problems, and besides which I understand this “fix” raises security issues. I can also get rid of this error by executing the following code before the submit.

document.getElementbyId(‘FolderBrowser’)..__VIEWST ATE.name="name";

This also causes other problems, and has unusual side effects on the page.

Can anyone help me?

Ken Shimizu
Everywhere Networks Corporation
Ottawa, Canada
[removed email address. please contact via PM]
Sep 5 '07 #1
Share this Question
Share on Google+
3 Replies


jhardman
Expert 2.5K+
P: 3,405
I get an error when submitting an .ASPX page in Safari beta, MAC and PC

document.getElementbyId(‘FolderBrowser’).submit();
Ken,

I removed your email address, because this is supposed to be a forum for discussions, others may want to see this solution.

In answer to your question, can you not say say:
[html]document.all.FolderBrowser.submit():[/html]? (Assuming that 'FolderBrowser" is the name of the form you are submitting)

Jared
Sep 6 '07 #2

P: 1
Ken,

That's the same problem I've been fighting for some time. I don't know how to solve this, except to keep looking for workarounds. I have no clue how to work around this issue. Removing the view state from the page does not fix. I implemented (from an article on 4GuysFromRolla) code that persists page state to a file - hoping this would be the solution.

I got further in Safari than before, but there is still an issue:

Expand|Select|Wrap|Line Numbers
  1. [HttpException (0x80004005): Unable to validate data.]
  2.    System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +2646292
  3.    System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +214
  4. System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +251
  5. System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
  6.    FileSystemPageStatePersister.Load() in c:\cccWebStore\WebStoreUI\App_Code\StatePersister\FileSystemPageStatePersister.cs:34
  7.    System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +83
  8.    System.Web.UI.Page.LoadAllState() +35
  9.  
  10.  
  11. [ViewStateException: Invalid viewstate. 
  12.     Client IP: 127.0.0.1
  13.     Port: 
  14.     User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/522.13.1 (KHTML, like Gecko) Version/3.0.2 Safari/522.13.1
  15.     ViewState: /wEPDwUKMTU0NjE1MjA3O...]
  16.  
  17. [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.]
  18.    System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +116
--------------------------------------------------
The line of code which is throwing that error is the line that translates what was retrieved from disk for the viewstate contents. This is on my development machine. Not production or remote.

pair = base.StateFormatter.Deserialize(contents) as Pair;

I appreciate any information that can be obtained from the experts here. It's a bug, yep. But how do we work around it?

BPerreault
Sep 13 '07 #3

P: 2
Ken,

I removed your email address, because this is supposed to be a forum for discussions, others may want to see this solution.

In answer to your question, can you not say say:
[html]document.all.FolderBrowser.submit():[/html]? (Assuming that 'FolderBrowser" is the name of the form you are submitting)

Jared
Sorry about the email address, I generally include it in all my correspondance. To answer your question, we used to use a simpler syntax to specify the form but we changed it to:

document.getElementbyId(‘FolderBrowser’).submit();

I believe (I'm not sure) we did it to make the code compatible with certain versions of Firefox.

By the way I found that the problem that I was having seemed to stem from the manner in which the previous form invoked the current form, when I changed the code to skip the previous form the error went away. So that's what I plan to do.

Ken
Sep 28 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.