Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
4.60/5 (3 votes)
See more:
Following error occurred when I am clicking on button on page. I hope it occurred when a request raised after session expired. Please give proper solution...


Server Error in '/' Application.
HTML
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\root\e529ecf2\18fea36a\App_Web_q6lqkkxv.13.cs    Line: 0

Stack Trace:

[ViewStateException: Invalid viewstate. 
	Client IP: 182.71.144.134
	Port: 2418
	User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0
	ViewState: /wEPDwULLTE5NTk1OTc2MjEPZBYCAgMPZBYEAh8PDxYCHgRUZXh0ZWRkAiEPPCsADQEADxYEHgtfIURhdGFCb3VuZGceC18hSXRlbUNvdW50AgNkFgJmD2QWDGYPDxYCHgdWaXNpYmxlaGRkAgEPZBYCZg9kFggCAQ8PFgQfAAUGdiBuYW1lHgdUb29sVGlwBRtodHRwOi8vd3d3LnRpbWVzb2ZpbmRpYS5jb21kZAIDDw8WAh8ABTdBZGRyZXNzLCBBZGRyZXNzLCAxMjMtMTIzLTEyMzQsIFMuIERlbGhpLCBEZWxoaSwgMTEwMDE3ZGQCBQ8PFgIfAAUBd2RkAgcPDxYCHwAFAjEyZGQCAg9kFgJmD2QWCAIBDw8WBB8ABQR0ZXN0HwQFEXd3dy55YWhvb21haWwuY29tZGQCAw8PFgIfAAUsdGVzdCwgdGVzdCwgMTIzLTQ1Ni03ODk1LCB0ZXN0LCB0ZXN0LCAyMDEzMDFkZAIFDw8WAh8ABQtEZXNjcmlwdGlvbmRkAgcPDxYCHwAFAjEzZGQCAw9kFgJmD2QWCAIBDw8WBB8ABQp0ZXN0dmVuZG9yHwQFFWh0dHA6Ly93d3cuc2RpYnNsLmNvbWRkAgMPDxYCHwAFSVRlc3QgQWRkcmVzcywgVGVzdCBBZGRyZXNzIDIsIDU1Ni01NjUtNTY1NSwgVGVzdCBDaXR5LCBUZXN0IFN0YXRlLCAyMDEzMDFkZAIFDw8WAh8ABRBUZXN0IERlc2NyaXB0aW9uZGQCBw8PFgIfAAUCMTlkZAIEDw8WAh8DaGRkAgUPDxYCHwNoZGQYAwUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFEGltZ2J0bkNhY2...]

[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) +237
   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.productlist_aspx.ProcessRequest(HttpContext context) in c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\e529ecf2\18fea36a\App_Web_q6lqkkxv.13.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.5448; ASP.NET Version:2.0.50727.5456
Posted
Updated 23-Sep-19 0:03am
v2
Comments
pataoengineer 1-Jun-12 4:30am    
Are you running the same website binary on the same machine (but published to different application)? I used to encounter this kind of problem when I duplicated webapp binaries into different application for testing purpose.

its all about machine key!
set a machine key in your config file!
use this link to generate a machine key:
machine key generator[^]
 
Share this answer
 
Comments
taha bahraminezhad Jooneghani 1-Jun-12 4:43am    
viewstate use machine key to encrypt , because u don't set it it use the host machine key and this problem happen!
if u set it in your config file problem will solved! it happens to me too!
Gaurav K Mishra 1-Jun-12 4:55am    
thanks for reply I am trying it.
taha bahraminezhad Jooneghani 1-Jun-12 5:02am    
and put the machine key under system.web section!
Gaurav K Mishra 1-Jun-12 6:19am    
Is The Machine Key generator secure? any security threat from that?
taha bahraminezhad Jooneghani 1-Jun-12 10:24am    
and you don't say,is your problem solved?
and if solved whay not a 5?:)
Please add this code in your web.config page :

C#
<system.web>
    <machinekey validation="SHA1" validationkey="A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1B2C3D4E5">
decryption="Auto" decryptionKey="A1B2C3D4E5F6F6E5D4C3B2A1A1B2C3D4E5F6F6E5D4C3B2A1" />
</machinekey></system.web>
 
Share this answer
 
Comments
CHill60 7-Aug-13 9:58am    
Doesn't add anything to taha bahrami's solution a year ago

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900