You must specify a non-autogenerated machine key to store passwords in the encrypted format.
Solution
If you attempt to use Reset Password to change to an Encrypted PasswordFormat but have not specified a MachineKey in web.config, the SqlMembership Provider will throw the following exception:
This exception is thrown by the SqlMembership provider when you attempt to store a password in an encrypted format but have not created a custom machineKey section in your web.config file. There are several reasons that a custom machineKey section is required by the Membership Provider:
- The machineKey defines a validation method, validationKey and decryptionKey which are used in the encryption/decryption algorithm.
- Normally, Asp.Net (and the .Net Framework) can autogenerate a machineKey, however, this would not be portable across machines. Since your web site may have to be moved from your development machine to a server or even onto a server farm, the "keys" for encrypting/decrypting passwords would not be available on those separate platforms unless they were explicitly defined.
How to specify a non-autogenerated machine key
Microsoft's MSDN site provides a full explanation of machineKeys and all of the options you have for controlling the way encryption will work in your web application. For many web applications, it may be enough to just add a <machineKey> section to web.config as illustrated here:<system.web> ... <machineKey validationKey= "2B53D41C080E6D7151146285D337D2F8008544D0D840CDD54A865255CD 4DD5F5D8D08F6528C95913BA7AF200586985FA0E6CFE5437EEA0CC6C6C29B8E7C14E45" decryptionKey= "32555827CFD4ADA6C56CAEC378029848484B12E0D0AF420E25F5E8F778B3C0DB" validation="SHA1" decryption="AES"/> ... </system.web>
Need a unique MachineKey?
For your convenience, we have used the CryptoServiceProvider to generate a unique <machineKey> section for you. Just copy it out of the text box below and use it on your own site(s).Other MachineKey related exceptions
If you do not have a MachineKey section in web.config, and attempt to Reset a Password, you may receive a message that indicates that the current password is encrypted but no MachineKey has been defined in web.config.Similarly, if you attempt to Change Question and Answer for a member whose password is encrypted but have removed the MachineKey from web.config, the Change Question and Answer panel will display a message similar to that shown below.
Important
When using Encrypted passwords, be sure to make a backup copy of your originalmachineKey data as it is the key to decrypting passwords.Related Topics
The Membership Manager ControlMembership Manager Configuration
Asp.Net SqlMembershipProvider Settings
Index was outside the bounds of the array
source :http://www.qualitydata.com/products/aspnet-membership/help/configuration/no-machinekey.aspx
Free Corner: ASP.Net, Programming, Programming Tool
0 ความคิดเห็น