自动生成的密钥不支持哈希或加密密码
我已经创建了一个会员提供程序并将我的 web.config 更改为,
<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 配置的安全页面时,都会出现以下错误:
自动生成的密码不支持散列或加密密码 在我的数据库中,
我使用 Identity 作为我的 PK。 我不知道这是不是问题。 但如果是的话我该如何解决呢? 我不想更改身份值。
谢谢。
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>
but now, whenever I try to browse to security page of ASP.Net Configuration it gives me the following error:
Hashed or Encrypted passwords are not supported with auto-generated keys
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.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为您正在对密码进行哈希处理,但尚未在 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:
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 :-)
去寻找“密钥生成器”片段有点笨拙
MSDN 链接 Steven Robbins 在他的回答中提到了,所以我添加放在这里以供快速参考。 所以这不是一个独立的答案。 它是对已接受答案的补充。
来自 MSDN
此外,
位于
内部,如下所示:Was a bit of a schlep to go hunting for the "key generator" snippet in the
MSDN link Steven Robbins referred to in his answer, so I am adding it here for quick reference. So this is not a standalone answer. It is supplemental to the accepted answer.
FROM MSDN
Also,
<machineKey>
goes inside of<system.web>
, like this: