Validation of viewstate MAC failed

Last Reply on Mar 25, 2015 12:31 PM By Shaiwal

Posted on Mar 20, 2015 12:57 AM

i have a webapplication hosted on web server. when i open page example login page , if i login after 2-3 mins or open any page after some time i face error, mentioned below. 

Please Help to resolve this Issue Or Write any artice for users to prevent or to resolve this, and Please Explain why this comes .

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

See http://go.microsoft.com/fwlink/?LinkID=314055 for more information.

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.

See http://go.microsoft.com/fwlink/?LinkID=314055 for more information.

Source Error: 

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

  <%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your application:

<configuration>
   <system.web>
       <compilation debug="true"/>
   </system.web>
</configuration>

Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

Stack Trace: 


[ViewStateException: Invalid viewstate. 
	Client IP: 14.98.31.134
	Port: 59961
	Referer: http://www.arpfashions.com/admin/index.aspx
	Path: /admin/index.aspx
	User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36
	ViewState: /wEPDwUKMTU2NDM2MDkyMWRkk6hfYEEbqr67MmNFq3XaOuz71TS6amCoulyv3+oFBks=]

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

See http://go.microsoft.com/fwlink/?LinkID=314055 for more information.]
   System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +116
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) +432
   System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter2.Deserialize(String serializedState, Purpose purpose) +8
   System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) +40
   System.Web.UI.HiddenFieldPageStatePersister.Load() +248
   System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +272
   System.Web.UI.Page.LoadAllState() +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6704
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245
   System.Web.UI.Page.ProcessRequest() +72
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
   System.Web.UI.Page.ProcessRequest(HttpContext context) +58
   ASP.admin_index_aspx.ProcessRequest(HttpContext context) +37
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237

Thanks


Posted on Mar 25, 2015 12:31 PM Modified on on Mar 25, 2015 12:31 PM

Hi @eshant.kapoor

Paste this code anywhere inside <system.web>......</system.web> in your web.config

<machineKey validationKey="308A5193B77D18BB33F286DCC941A54331AE8D000104EAC1DB843D98B1CB457AF9A813B4D5D7D77220987AC8EA478401577194FC20E6CCE8ACEC159C5C59D754" decryptionKey="46C25F7D8BFDE6DAF886AEC2706EFA6A2706C43C752B69C82D5B13A29EA246C1" validation="SHA1" decryption="AES" />

This will definately solve your issue.

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html