自动生成的密钥不支持哈希密码或加密密码 [英] Hashed or Encrypted passwords are not supported with auto-generated keys

查看:80
本文介绍了自动生成的密钥不支持哈希密码或加密密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个成员资格提供程序,并将我的web.config更改为

I have create a Membership provider and changed my web.config to

<membership defaultProvider="MyMembershipProvider">
   <providers>
     <clear/>
     <add name="MyMembershipProvider"
          type="Khafan.Providers.SqlMembershipProvider"
          connectionStringName="KhafanConnectionString"  
          maxInvalidPasswordAttempts="5"             
          passwordAttemptWindow="10"
          minRequiredNonalphanumericCharacters="0"
          minRequiredPasswordLength="4"
          passwordStrengthRegularExpression=""
          passwordFormat="Hashed"
          enablePasswordReset="true"
          enablePasswordRetrieval="false"             
          requiresQuestionAndAnswer="false"
          requiresUniqueEmail="true" />
   </providers>
 </membership>

但是现在,每当我尝试浏览到ASP.Net Configuration的安全页面时,都会出现以下错误:

but now, whenever I try to browse to security page of ASP.Net Configuration it gives me the following error:

自动生成的密钥不支持哈希密码或加密密码

在我的数据库中,我已经使用身份作为我的PK.我不知道这是不是问题.但是,如果是的话,我该如何解决呢?我不想更改身份值.

In my database I have used Identity for my PKs. I don't know it is the problem or not. But if it is, how can I solve it? I don't want to change Identity values.

谢谢.

推荐答案

这是因为您正在哈希密码,但尚未在web.config中设置特定密钥.此 MSDN文章中有一个密钥生成器"代码段,运行两次并将它们推送到您的web.config中,如下所示:

This is because you are hashing passwords but haven't set specific keys in your web.config. There's a "key generator" snippet in this MSDN article, run it twice and shove them in your web.config as:

<system.web>
    <machineKey  
    validationKey="<blah>"           
    decryptionKey="<blah>"
    validation="SHA1"
    decryption="AES"
    />

这应该可以解决您的问题.之所以这样,是因为否则您可以将您的会员数据库/应用程序带到另一台机器上,并且您的密码都不起作用,因为自动生成的机器密钥会有所不同:-)

And that should sort you out. It's like this because otherwise you could take your membership database/app to another machine and none of your passwords would work, as the auto generated machine keys would be different :-)

这篇关于自动生成的密钥不支持哈希密码或加密密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆