Hi,
I have around 60 pages in my application. Out of which, I am using Infragistics webdropdown on 13 pages. The dropdown version is 12.1.20121.1005. Recently, I got a requirement to encrypt the viewstate for my application as it was only Base-64 encoded by default. I included a tag "ViewStateEncryptionMode=always" in web.config. After doing that, I found that all of the pages are functioning properly, but as soon as I click on a page using Infragistics webdropdown, I get the below exception: FYI, I have disabled viewstateMAC on all of the pages but still getting the same issue only on these 13 pages.
I am using a defined machine key for encryption in the web.config and my application is not a web farm. Since, I am seeing this exception only on pages having webdropdown, this makes me think if there is something in the design of webdropdon which is triggering this exception.
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.[ViewStateException: Invalid viewstate. Client IP: 127.0.0.1Port: Referer: http://localhost:49677/APPLICATIONNAME/PAGE.aspx?Menu=WIPath: /APPLICATIONNAME/PAGE.aspxUser-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E; PRU_IE)ViewState: aQ7noZuaXWuJ8xkL46f3p6UqKODAT5kdBepkB7QhF9EaceeD4shqb/0bjK/3I2VSiIwWz+OJrHuKW/ZlaVUDAUHouhJwrWQCH6iHAJ0hFUIrJPK3toPGMTY91bXqFZ6I5gAM5jyPi0hiWffNGhMbGkK6Mws7abPFhkA15dqpUTJEr7nmntHtNynReIvh+bJDVK0CSnQyVpVfAhDe0yffK35DYf5BUOBPz/qG+kjhh+FyHiSM7dmbHIbpmV/1JQqV7VC3nwe5Z1OLtGgdQrA6+0kMqT0rcjz5+r8yZy2JQjXew16BSa5O+O535nUlvTxpi+U9/gPIj+zmbJ6MQgTFmeoE1ISUu/SQHTJVYyD8uZ+JFSw6jGnzqrqm7GwBziUEP//BHXAAuTFvasK4QL22Kvj4rMsJfPGtZriTABgZKs2M2zjo32aRPxEdkYX5dLgt01EeBLQIMdfG5IpIHyScrv/jZtbIZs2qm5r5xfdmNAjSNNKyi1RvBp08KkbClHq952SqXShvIWoWN2BCJzxQSu5uHvqifZ4DMfdDkRcButikm1BihWWz6K8y9wHKFl8lYGVgTQWjSkW6h354rqNcZVCAeoxQLi8asFf4thH0hCOgI8CtOeYkNz70JKNF70x4P8GR54UFPPoBdOJg3IFwlpT0UydrNwxYGTglh...][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) +235 System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) +14 System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +274 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() +241 System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +106 System.Web.UI.Page.LoadAllState() +43 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253 System.Web.UI.Page.ProcessRequest() +78 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21 System.Web.UI.Page.ProcessRequest(HttpContext context) +49 ASP.icasdet_aspx.ProcessRequest(HttpContext context) +37 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Hello SuniMehta,
What I can suggest is ensuring that you have included all the necessary resources in the deployment package of your application. Some further reference about deployment could be found at:
http://help.infragistics.com/Help/NetAdvantage/WinForms/2012.2/CLR4.0/html/Win_Deployment_Overview.html
Another possible cause for this exception might be the reason that Control using DataKeyNames require Viewstate to be encrypted. When Viewstate is encrypted (Default mode, Auto, is to encrypt if controls require that, otherwise not), Page adds <input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" /> field just before closing of the <form> tag. But this hidden field might not have been rendered to the browser with long-running pages, and if you make a postback before it does, the browser initiates postback without this field (in form post collection). End result is that if this field is omitted on postback, the page doesn't know that Viewstate is encrypted and causes the aforementioned Exception. I.E. page expects to be fully-loaded before you make a postback. Possible solutions of the issue as well as some further reference could be found at:
http://blogs.msdn.com/b/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx
If this suggestions are not helping you to resolve the issue a small isolated sample where the issue is reproducible would be highly appreciated and would help me to investigate further.
Looking forward to hearing from you.
I am still following your case. Have you been able to resolve the issue?
Feel free to contact me if you need any further assitance with this matter.