oracle 升级到 VS 2010 / .NET 4.0 后,Membership.ValidateUser 总是返回 false

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2730020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 20:31:23  来源:igfitidea点击:

Membership.ValidateUser always returns false after upgrade to VS 2010 / .NET 4.0

c#asp.netoracleasp.net-membership

提问by nw.

Not sure whether this pertains to VS 2010 or to the upgraded framework, but... we are using the Oracle membership provider to authenticate users. Prior to the upgrade everything worked fine, but now Membership.ValidateUser(user, password)returns falsedespite valid credentials. There is no exception thrown, so it's hard to determine what the problem might be. The website administration tool in VS 2010 is still able to manage users and roles (more or less), so I have no reason to question connectivity. What might the problem be?

不确定这是否与 VS 2010 或升级后的框架有关,但是...我们正在使用 Oracle 成员资格提供程序来验证用户。在升级之前一切正常,但现在尽管有效凭据仍然Membership.ValidateUser(user, password)返回false。没有抛出异常,因此很难确定可能是什么问题。VS 2010 中的网站管理工具仍然能够管理用户和角色(或多或少),所以我没有理由质疑连通性。可能是什么问题?

采纳答案by nw.

The answer (according to this post) is to specify hashAlgorithmType="SHA1"in the Web.config:

答案(根据这篇文章)是hashAlgorithmType="SHA1"在 Web.config 中指定:

<membership defaultProvider="OracleMembershipProvider" hashAlgorithmType="SHA1"/>

This did not solve the problem for existing users, but newly created users can log in now.

这并没有解决现有用户的问题,但新创建的用户现在可以登录。

回答by PussInBoots

Sounds a little bit like the problem I am having..

听起来有点像我遇到的问题..

Adding a machineKey element to web.config instead of hashAlgorithmType="SHA1" fixed the problem.. but I still don't understand why I need to put that there... haven't been able to find any documentation either..

将 machineKey 元素添加到 web.config 而不是 hashAlgorithmType="SHA1" 解决了这个问题..但我仍然不明白为什么我需要把它放在那里......也找不到任何文档......

You can check out my question here.. The user name or password provided is incorrect. in MVC 3 Internet Application

你可以在这里查看我的问题.. 提供 的用户名或密码不正确。在 MVC 3 Internet 应用程序中

回答by Sky Sanders

You may be experiencing machineKey disparity.

您可能会遇到 machineKey 差异。

In web.config - the implicit machineKeysection uses autogenerated encryption and validation keys that are again keyed against the app Id (AutoGenerate,IsolateApps).

在 web.config 中 - 隐式machineKey部分使用自动生成的加密和验证密钥,这些密钥再次根据应用程序 ID ( AutoGenerate,IsolateApps) 进行加密。

Are you testing with a different application instance or on another machine?

您是使用不同的应用程序实例还是在另一台机器上进行测试?

Is the Oracle membership provider 2.0 or 4.0?

Oracle 会员提供程序是 2.0 还是 4.0?

And this is just a stab in the dark, maybe this will lead you to a solution.

From .NET Framework 4 Migration Issues

Membership types

Some types (for example, System.Web.Security.MembershipProvider) that are used in ASP.NET membership have been moved from System.Web.dll to the System.Web.ApplicationServices.dll assembly. The types were moved in order to resolve architectural layering dependencies between types in the client and in extended .NET Framework SKUs.

而这只是在黑暗中的一次尝试,也许这会引导您找到解决方案。

.NET Framework 4 迁移问题

会员类型

ASP.NET 成员资格中使用的某些类型(例如 System.Web.Security.MembershipProvider)已从 System.Web.dll 移至 System.Web.ApplicationServices.dll 程序集。移动这些类型是为了解决客户端中的类型与扩展的 .NET Framework SKU 中的类型之间的体系结构分层依赖关系。

Class libraries that have been upgraded from earlier versions of ASP.NET and that use membership types that have been moved might fail to compile when used in an ASP.NET 4 project. If so, add a reference in the class library project to System.Web.ApplicationServices.dll

在 ASP.NET 4 项目中使用时,从早期版本的 ASP.NET 升级并使用已移动的成员资格类型的类库可能无法编译。如果是,在类库项目中添加对System.Web.ApplicationServices.dll的引用