title: The anti-forgery token could not be decrypted even in localhost?
body: <p>Even though I am running in localhost, my mvc web site gives me this error:</p>
  
  <p><strong><em>The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the  configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.</em></strong></p>
  
  <p>I used this machinekey:</p>
  
  <pre><code>&lt;machineKey compatibilityMode="Framework20SP1" validationKey='AC0DA63E787522E3BA5D47D8FA0A46EB68BB89A35C6353D5E8D3D5CA416D0DA607E56C6D0861ED3B7194C3ED74C0CE79FE4CE2909F34A6CFBDE134C1A094CA40' decryptionKey='A68360896EF374401123C6C222A7AAD8D430DB4DE34938E1' validation='SHA1'/&gt;
  </code></pre>
  
  <p>But still no use. In addition, I extracted this machinekey from a third party. I know it is not safe but the microsoft way is too complicated: using powershell to generate it? complicated. Then using IIS? My IIS8 is not showing machinekey module. What on earth is going on with all of these stuff.</p>
  
  <p>Okay, maybe the error is caused by a multiple @html.antiforgerytoken. Well, I had indeed two antiforgerytoken, but when I remove one of them, the error persisted.</p>
  
  <p>I am so frustated with this problem. I hope someone will be kind enough to help. I believe those MVC users have been in this situation when developing MVC web site. In my case, I am just a newbie and this is my first MVC web site that is deployed.</p>
  
  <p>thanks for you help</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>controller:</p>
  
  <pre><code>// POST: /Account/Manage
      [HttpPost]
      [ValidateAntiForgeryToken]
      public async Task&lt;ActionResult&gt; Manage(ManageUserViewModel model)
      {
          bool hasPassword = HasPassword();
          ViewBag.HasLocalPassword = hasPassword;
          ViewBag.ReturnUrl = Url.Action("Manage");
          if (hasPassword)
          {
              if (ModelState.IsValid)
              {
                  IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);
                  if (result.Succeeded)
                  {
                      return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
                  }
                  else
                  {
                      AddErrors(result);
                  }
              }
          }
          else
          {
              // User does not have a password so remove any validation errors caused by a missing OldPassword field
              ModelState state = ModelState["OldPassword"];
              if (state != null)
              {
                  state.Errors.Clear();
              }
  
              if (ModelState.IsValid)
              {
                  IdentityResult result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword);
                  if (result.Succeeded)
                  {
                      return RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess });
                  }
                  else
                  {
                      AddErrors(result);
                  }
              }
          }
  
          // If we got this far, something failed, redisplay form
          return View(model);
      }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>@using percobaan2.Models;
  @using Microsoft.AspNet.Identity;
  @{
  ViewBag.Title = "Manage Account";
  Layout = "~/Views/Shared/_LayoutManage.cshtml";
  }
  
  &lt;div class="row-fluid"&gt;
  &lt;div class="span4 offset4 blog-details"&gt;
  
      &lt;p class="text-success"&gt;@ViewBag.StatusMessage&lt;/p&gt;
  
      @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
      {
          @Html.AntiForgeryToken()
          @Html.ValidationSummary(true)
  
          &lt;article class="center"&gt;
  
              @if (ViewBag.HasLocalPassword)
              {
                  @Html.Partial("_ChangePasswordPartial")
              }
              else
              {
                  @Html.Partial("_SetPasswordPartial")
              }
  
          &lt;/article&gt;
      }
  &lt;/div&gt;
  &lt;/div&gt;
  
  @section Scripts {
  @Scripts.Render("~/bundles/jqueryval")
  }
  </code></pre>
  
  <p>Layout:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;!-- META DATA --&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"&gt;
  &lt;meta name="apple-mobile-web-app-capable" content="yes"&gt;
  &lt;meta name="apple-mobile-web-app-status-bar-style" content="black"&gt;
  
  &lt;meta name="description" content="@ViewBag.WebsiteTitle"&gt;
  
  &lt;title&gt;@ViewBag.Title - @ViewBag.WebsiteTitle&lt;/title&gt;
  
  &lt;link rel="shortcut icon" href="assets/images/ico/favicon.png"&gt;
  
  @Styles.Render("~/Content/css")
  @Scripts.Render("~/bundles/modernizr")
  
  &lt;!-- GOOGLE WEB FONTS --&gt;
  &lt;link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,700,600,300,800' rel='stylesheet' type='text/css'&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;!-- NAVIGATION --&gt;
  &lt;nav class="fixed-top fixed-visable" id="navigation"&gt;
      &lt;div class="container"&gt;
          &lt;div class="row-fluid"&gt;
              &lt;div class="span12 center"&gt;
                  &lt;!-- MOBILE MENU BUTTON --&gt;
                  &lt;div class="mobile-menu" data-toggle="collapse" data-target=".nav-collapse"&gt;
                      &lt;span class="icon-bar"&gt;&lt;/span&gt;
                      &lt;span class="icon-bar"&gt;&lt;/span&gt;
                      &lt;span class="icon-bar"&gt;&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;!-- END MOBILE MENU BUTTON --&gt;
                  &lt;!-- MAIN MENU --&gt;
                  &lt;ul id="main-menu" class="nav-collapse collapse"&gt;
                      &lt;li&gt;&lt;a href="@Url.Action("Edit", "Home", new { Area = "Admin", id = 1 })"&gt;Home&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="@Url.Action("Index", "Slide", new { Area = "Admin" })"&gt;Tagline&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="@Url.Action("Index", "Division", new { Area = "Admin" })"&gt;Division&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="@Url.Action("Index", "Contact", new { Area = "Admin" })"&gt;Yahoo&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="@Url.Action("Index", "Email", new { Area = "Admin" })"&gt;Email&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="@Url.Action("Index", "Product", new { Area = "Admin" })"&gt;Product&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="@Url.Action("Index", "Category", new { Area = "Admin" })"&gt;Category&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="@Url.Action("Index", "Producer", new { Area = "Admin" })"&gt;Producer&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="@Url.Action("Index", "Unit", new { Area = "Admin" })"&gt;Unit&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="@Url.Action("Index", "Activity", new { Area = "Admin" })"&gt;Activity&lt;/a&gt;&lt;/li&gt;
                      @*@Html.Partial("_LoginPartial")*@
                  &lt;/ul&gt;
                  &lt;!-- END MAIN MENU --&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/nav&gt;
  &lt;!-- END NAVIGATION --&gt;
  &lt;!-- PAGE | BLOG --&gt;
  &lt;div class="pages page-blog-list" id="page-blog-list"&gt;
      &lt;div class="container"&gt;
          &lt;!-- Header --&gt;
          &lt;header id="headerUpper" class="headerAdmin"&gt;
              &lt;h4 class="line-divider"&gt;Admin&lt;/h4&gt;
              &lt;h1&gt;Change Password&lt;/h1&gt;
          &lt;/header&gt;
          &lt;!-- End Header --&gt;
  
              @RenderBody()
  
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;!-- END PAGE | BLOG --&gt;
  
  @Scripts.Render("~/bundles/jquery")
  @Scripts.Render("~/bundles/bootstrap")
  @Scripts.Render("~/bundles/plugins")
  @Scripts.Render("~/bundles/blog")
  @RenderSection("scripts", required: false)
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Login Partial:</p>
  
  <pre><code>@using Microsoft.AspNet.Identity
  @if (Request.IsAuthenticated)
  {
  using (Html.BeginForm("LogOff", "Account", new { Area = "" }, FormMethod.Post, new { id = "logoutForm" }))
  {
      @Html.AntiForgeryToken()
  
      &lt;li&gt;
          @Html.ActionLink("Account", "Manage", "Account", new { Area = "" }, htmlAttributes: new { title = "Manage" })
      &lt;/li&gt;
  
      &lt;li&gt;
          &lt;a href="javascript:document.getElementById('logoutForm').submit()"&gt;
              Log off
          &lt;/a&gt;
      &lt;/li&gt;
  
      @*&lt;li&gt;
              @Html.ActionLink("Account", "Manage", "Account", new { Area = "" }, htmlAttributes: new { title = "Manage", @class = "phoneNumber" })
          &lt;/li&gt;
  
          &lt;li&gt;
              &lt;a href="javascript:document.getElementById('logoutForm').submit()" class="phoneNumber logOffPadding"&gt;
                  Log off
              &lt;/a&gt;
          &lt;/li&gt;*@
  
  }
  }
  else
  {
  @*@Html.ActionLink("Register", "Register", "Account", new { Area = "" }, htmlAttributes: new { id = "registerLink", @class = "phoneNumber" })*@
  
  &lt;li&gt;
      @Html.ActionLink("Log in", "Login", "Account", new { Area = "" }, htmlAttributes: new { id = "loginLink", @class = "phoneNumber logInPadding" })
  &lt;/li&gt;
  }
  </code></pre>
  
  <p><strong>.NET Vesion: 4.5</strong></p>