Exception type: CryptographicException

Recently we started getting the following error message on our ASP.NET 2.0 web application running on IIS6.

  • Exception type:
    • CryptographicException
  • Exception message:
    • Padding is invalid and cannot be removed.
  • Stack trace:
    • at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
    • at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
    • at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
    • at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Boolean useValidationSymAlgo)
    • at System.Web.UI.Page.DecryptString(String s)
    • [...]

The application provides forms authentication as the login mechanism for the end-user.

To see how I fixed this see my article on JoeTheWebGuy.net.

No Comments