title: MVC Anti forgery token validating even though no [ValidateAntiForgeryToken]
body: <p>I have the dreaded Validation of viewstate MAC failed problem from time to time. I run my application in a web farm and have set the machine key of the application to the same value on all web servers. 
  I have been doing some experiments and now I have two questions regarding the anti forgery token mechanism: <br/><br/>
  1. I seem to get this error even though I'm not calling any action with the [ValidateAntiForgeryToken] attribute (the problem seems to appear when rendering the token in the view). Why is this happening? Isn't the validation supposed to only run when the attribute is present. The problem dissappears if the __RequestVerificationToken  cookie is removed.
  <br/><br/>
  2. Isn't the __RequestVerificationToken cookie supposed to be a session cookie and thus be invalid as the session expires? This doesn't seem to be the case?</p>
  
  <p>Stack trace:</p>
  
  <blockquote>
    <p>A required anti-forgery token was not supplied or was invalid</p>
    
    <p>at System.Web.Mvc.AntiForgeryDataSerializer.Deserialize(String
    serializedToken) <br/> at
    System.Web.Mvc.HtmlHelper.GetAntiForgeryTokenAndSetCookie(String salt,
    String domain, String path) <br/> at
    System.Web.Mvc.HtmlHelper.AntiForgeryToken(String salt, String domain,
    String path) <br/> at System.Web.Mvc.HtmlHelper.AntiForgeryToken()
    <br/> at
    ASP.views_customer__customerlogin_ascx.__Render__control1(HtmlTextWriter
    __w, Control parameterContainer) <br/> at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
    ICollection children) <br/> at
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
    ICollection children) <br/> at
    System.Web.UI.Page.Render(HtmlTextWriter writer) <br/> at
    System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) <br/> at
    System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    <br/> at System.Web.UI.Page.ProcessRequest(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    <br/> at System.Web.UI.Page.ProcessRequest() at
    System.Web.UI.Page.ProcessRequest(HttpContext context) <br/> at
    System.Web.Mvc.ViewUserControl.ViewUserControlContainerPage.ProcessRequest(HttpContext
    context) <br/> at System.Web.Mvc.ViewPage.RenderView(ViewContext
    viewContext) <br/> at
    System.Web.Mvc.ViewUserControl.RenderViewAndRestoreContentType(ViewPage
    containerPage, ViewContext viewContext) <br/> at
    System.Web.Mvc.HtmlHelper.RenderPartialInternal(String
    partialViewName, ViewDataDictionary viewData, Object model, TextWriter
    writer, ViewEngineCollection viewEngineCollection) <br/> at
    System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper
    htmlHelper, String partialViewName, Object model) at
    ASP.views_cart_index_aspx.__Rendercontainer_main(HtmlTextWriter __w,
    Control parameterContainer) <br/> at
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
    ICollection children) at
    ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w,
    Control parameterContainer) at
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
    ICollection children) <br/> at
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
    ICollection children) at System.Web.UI.Page.Render(HtmlTextWriter
    writer) <br/> at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
    at System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest() at
    System.Web.UI.Page.ProcessRequest(HttpContext context) <br/> at
    System.Web.Mvc.ViewPage.ProcessRequest(HttpContext context) at
    ASP.views_cart_index_aspx.ProcessRequest(HttpContext context) <br/> at
    System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.&lt;>c__DisplayClass1.b__0()
    at
    System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.&lt;>c__DisplayClass4.b__3()
    <br/> at
    System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1
    func) <br/> at
    System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap(Action
    action) <br/> at
    System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler,
    TextWriter writer, Boolean preserveForm, Boolean setPreviousPage,
    VirtualPath path, VirtualPath filePath, String physPath, Exception
    error, String queryStringOverride)<br/></p>
  </blockquote>
  
  <p><strong>Inner exception</strong><br/><br/></p>
  
  <blockquote>
    <p>Validation of viewstate MAC failed. If this application is hosted by a
    Web Farm or cluster, ensure that  configuration specifies
    the same validationKey and validation algorithm. AutoGenerate cannot
    be used in a cluster.</p>
  </blockquote>