'Padding is invalid and cannot be removed.'

Discussion in 'ASP.NET 2.0' started by Harvey Birdman, Jan 8, 2008.

  1. Hey, all -

    Getting weird error messages from my site, the gist of which is in the subject line. According to what I've read it seems related to the internal use of cryptography in the ViewState; the remedy is supposed to be specifying a machineKey in web.config. I've done that, and for a while it seemed the problem had gone away. Made some minor updates yesterday and now the problem is back. I don't really know that the resumption of errors is related to my updates... but the timing is curious.

    Anyone have any ideas? [​IMG]
     
  2. Can you provide the exact error messages or a link to the page that causes the error ?

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.
    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)
    at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    Padding is invalid and cannot be removed.

    *****************************

    That's all I can tell you. I can tell you that I'm not doing anything intentionally with cryptography, and the machineKey entry I created specified SHA1 for validation and AES for decryption, while the message seems related to Rijndael encryption. Or am I misreading it?

    Post Edited (Harvey Birdman) : 1/8/2008 11:26:22 PM GMT
     
  4. Yeah,I'd seen both of those. The best information I could find was here - http://www.developmentnow.com/articles/machinekey_generator.aspx . It seemed to do the trick for a while, but not any more.





    When I updated my sight yesterday, I uploaded a pre-compiled, non-updatable version using Expression. I didn't upload all the folders - two folders contain static stuff that didn't change, and are many megabytes in size, so I left the old version there.


    I wonder if that could have something to do with it.
     

Share This Page