Problems using Submit button between pages

admin

Administrator
Staff member
I am getting an error when going between links of each page. I have a login page but also have links to "Register New User" and "Forgot Password". I have validation on each page, but when I click on the link from (Example) "Login Page" to "Forgot Password" and then click the submit button (To test validation) to process the form, I get an error (See Below) and no validation is rendered. I can get the validation to work on all pages. It just seems that every time I hyperlink to each page, it doesn't fire the validation. Should I disable ViewState for each page, would that help? Or do I need to initialize/clear ViewState for each page that I hyperlink to?



Error Message after clicking on the submit button.
Server Error in '/' Application.
--------------------------------------------------------------------------------

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:

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.MachineKey.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +196
System.Web.UI.LosFormatter.Deserialize(String input) +60

[HttpException (0x80004005): Authentication of viewstate failed. 1) If this is a cluster, edit <machineKey> configuration so all servers use the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. 2) Viewstate can only be posted back to the same page. 3) The viewstate for this page might be corrupted.]
System.Web.UI.LosFormatter.Deserialize(String input) +118
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +102

[HttpException (0x80004005): Invalid_Viewstate
Client IP: 68.132.73.25
Port: 3184
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
ViewState: dDwyMTA4MDAzNDk4OztsPGNrUGVyc2lzdDs+PgBgwwf8rg7x3lLaAsn+X8hoWAMA
Http-Referer:
Path: /login.aspx.]
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +443
System.Web.UI.Page.LoadPageViewState() +18
System.Web.UI.Page.ProcessRequestMain() +447




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET Version:1.1.4322.2300I found this on a website and it fixed the problem:
HttpException :: Unable to validate data
If you are receiving HttpExceptions in your ASP.NET applications on postbacks; saying, Unable to validate data, you may try setting enableViewStateMac to true. You can do so at page level or for entire site in web.config.

<configuration>
<system.web>
<pages enableViewStateMac="false" />
</system.web>
</configuration>


But, Microsoft's MSDN says not to use it, now I'm torn....
This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
<!-- m --><a class="postlink" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIPageClassEnableViewStateMacTopic.asp">http://msdn.microsoft.com/library/defau ... cTopic.asp</a><!-- m -->

Why shouldn't someone use this code?
 
Back
Top