“Padding is Invalid and cannot be removed” exception on WebResource.axd

后端 未结 3 2183
悲&欢浪女
悲&欢浪女 2020-12-05 02:43

I have an ASP.NET 2.0 application that is working fine in our local environment. When published to a test server, we\'re getting intermittent errors on the server.

3条回答
  •  生来不讨喜
    2020-12-05 03:08

    Ben,

    For your first problem, I found this that seems to be a bit more to the point of what you are seeing in that the problem is sporadically occurring. You should be able to find a full explanation of this at http://www.codeproject.com/KB/security/Cryptor.aspx#aes.

    What you really need to do is set RijndaelAlg.Padding to PaddingMode.ISO10126, PaddingMode.PKCS7, or PaddingMode.ANSIX923. Any one of these 3 values should work, provided that you use the same value when encrypting and decrypting. Other values will work with some data, but not with all data. The above URL explains why.

    What I don't understand is the reason Microsoft provides options that sometimes don't work, or at least why they don't default to a reliable option.

提交回复
热议问题