title: "Error occurred during a cryptographic operation" when decrypting Forms cookie
body: <p>I've uploaded my website to a webhosting and this error came up; <br/>
  '<strong>Error occurred during a cryptographic operation</strong>.'.<br/>
  <br/>
  I've done some research and it seems that the formauthenticated cookie is bound to the MachineKey (which differs when using webhost).<br/></p>
  
  <p><br/>
  I've found a method that should fix this problem but the error remains.<br/>
  <br/>
  <strong>CODE:</strong><br/></p>
  
  <pre><code>/// &lt;summary&gt;
      /// This method removes a cookie if the machine key is different than the one that saved the cookie;
      /// &lt;/summary&gt;
      protected void Application_Error(object sender, EventArgs e)
      {
          var error = Server.GetLastError();
          var cryptoEx = error as CryptographicException;
          if (cryptoEx != null)
          {
              FederatedAuthentication.WSFederationAuthenticationModule.SignOut();
              Global.Cookies.FormAuthenticated Cookie = new Global.Cookies.FormAuthenticated();
              Cookie.Delete();
              Server.ClearError();
          }
      }
  </code></pre>
  
  <p><br/>
  <strong>STACKTRACE:</strong><br/></p>
  
  <pre><code>[CryptographicException: Error occurred during a cryptographic operation.]
     System.Web.Security.Cryptography.HomogenizingCryptoServiceWrapper.HomogenizeErrors(Func`2 func, Byte[] input) +115
     System.Web.Security.Cryptography.HomogenizingCryptoServiceWrapper.Unprotect(Byte[] protectedData) +59
     System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket) +9824926
     Archive_Template.Main.resolveLoginUser(String sessionKey) in f:\Archive_Template\Archive_Template\Main.aspx.cs:481
     Archive_Template.Main.OnPreInit(EventArgs e) in f:\Archive_Template\Archive_Template\Main.aspx.cs:52
     System.Web.UI.Page.PerformPreInit() +31
     System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +335
  </code></pre>