1
//validationKey = CreateKey(20);
//decryptionKey = CreateKey(24);
byte[] bytes = new byte[len];
new RNGCryptoServiceProvider().GetBytes(bytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
sb.Append(string.Format("{0:X2}", bytes[i]));
}
sb.ToString();
求2次值。
把值sb.ToString();放到webconfig里
<system.web>
<machineKey validationKey="D7AE3806F70599FCD07EDEE09C8AEFD337414FE2"
decryptionKey="31F6CA4CA0517794D78DF0BCD57DBE9CEA5EA80A1FB2BFED" decryption="3DES" validation="SHA1"/>
</system.web>
2 在当前页面的<page ...>里加两个属性:
enableEventValidation="false" viewStateEncryptionMode ="Never"