{"id":1289,"date":"2017-07-09T20:27:50","date_gmt":"2017-07-09T20:27:50","guid":{"rendered":"https:\/\/www.xsofthost.com\/help\/?p=1289"},"modified":"2021-03-16T00:47:59","modified_gmt":"2021-03-16T00:47:59","slug":"asp-net-validation-of-viewstate-mac-failed-on-iis-windows-server","status":"publish","type":"post","link":"https:\/\/www.xsofthost.com\/help\/asp-net-validation-of-viewstate-mac-failed-on-iis-windows-server\/","title":{"rendered":"Validation of viewstate MAC failed On asp.net windows server"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"1289\" class=\"elementor elementor-1289\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-ab7ff5a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"ab7ff5a\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-e0483ff\" data-id=\"e0483ff\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-4b39480 elementor-widget elementor-widget-text-editor\" data-id=\"4b39480\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster<\/p>\n<p>some general errors you may face , when you earn dedicated server with windows server and host your website applications on IIS service is<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-273f1a9 elementor-widget elementor-widget-code-highlight\" data-id=\"273f1a9\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard word-wrap\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-aspnet \">\n\t\t\t\t<code readonly=\"true\" class=\"language-aspnet\">\n\t\t\t\t\t<xmp>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.\n\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b14634f elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b14634f\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-42aaa6a\" data-id=\"42aaa6a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-add010b elementor-widget elementor-widget-heading\" data-id=\"add010b\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Why i\u2019m seeing Validation of viewstate MAC failed\n<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bc9610a elementor-widget elementor-widget-text-editor\" data-id=\"bc9610a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>The ViewState is a mechanism built in to the ASP.NET platform for persisting elements of the user interface and other data across successive requests. The data to be persisted is serialized by the server and transmitted via a hidden form field.<\/p>\n<p>This kind of error caused by aps.net worker process or by server IIS recycling the process.The nature of ASP.NET process is to encrypt the viewstate by using Autogenerated Key when the process spins up ,The problem comes when a client (browser) sends the request with a viewstate encrypted with the key generated by another worker process. Since the key is different, ASP.NET will not be able to decrypt the viewstate and it will throw the above error.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f6ef4da elementor-widget elementor-widget-heading\" data-id=\"f6ef4da\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">How to solve ASP.NET Validation of viewstate MAC failed\n<\/h3>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-72365cf elementor-widget elementor-widget-text-editor\" data-id=\"72365cf\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>There are several steps or options that you might workaround to solve the issue<\/p>\n<ol>\n<li>Host your site on a server where the application pools never recycle! Obviously, this is impossible.<\/li>\n<li><strong>Disable<\/strong>\u00a0ViewstateMac by putting this \u201c<strong><em>enableViewStateMac=\u201dfalse<\/em><\/strong>\u201c\u201d in your web.config on Pages tag under system.web tag. Please note that this step is not 100% secure \u201cand\u00a0<strong>NOT<\/strong>\u00a0recommended\u201d.<\/li>\n<li>Configure ASP.NET to not use Auto-Generated Key but rather a predefined key.\u00a0<strong>This is the perfect and secure method .<\/strong><\/li>\n<li>\u00a0<\/li>\n<\/ol>\n<p>To generate your key by yourself use <a style=\"font-family: var( --e-global-typography-text-font-family ), Sans-serif; font-weight: var( --e-global-typography-text-font-weight );\" title=\"How to create keys by using Visual Basic .NET for use in Forms authentication\" href=\"https:\/\/en.wikipedia.org\/wiki\/Windows_shell\" target=\"_blank\" rel=\"noopener\">Windows Shell<\/a><\/p>\n<p><span style=\"color: var( --e-global-color-text ); font-family: var( --e-global-typography-text-font-family ), Sans-serif; font-weight: var( --e-global-typography-text-font-weight );\">and then your web.config should like<\/span><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-743be87 elementor-widget elementor-widget-code-highlight\" data-id=\"743be87\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard word-wrap\">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-aspnet line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-aspnet\">\n\t\t\t\t\t<xmp><machineKey validationKey=\u201d08CE6B478DCE73\u2026\u2026\u2026.E566D8AC5D1C045BA60\u2033\ndecryptionKey=\u201d4252D6B2268\u2026\u2026\u202667F451CE65D0F2ABE9BCD3A\u201d\nvalidation=\u201dSHA1\u2033>\n<\/machineKey>\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster some general errors you may face , when you earn dedicated server with windows server and host your website applications on IIS service is Validation of viewstate MAC failed. If this application is hosted by a Web Farm or [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":998,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[75,180],"tags":[178,99,74,77],"_links":{"self":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts\/1289"}],"collection":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/comments?post=1289"}],"version-history":[{"count":53,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts\/1289\/revisions"}],"predecessor-version":[{"id":2460,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/posts\/1289\/revisions\/2460"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/media\/998"}],"wp:attachment":[{"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/media?parent=1289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/categories?post=1289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xsofthost.com\/help\/wp-json\/wp\/v2\/tags?post=1289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}