System.NotSupportedException: Specified method is not supported

放肆的年华 提交于 2020-01-03 13:11:08

问题


Is it possible to get the password of a user? How, please? When I've tried this code :

WebSecurity.InitializeDatabaseConnection("nectarys-pc.MonitoringN.dbo", "Superviseur", "UserId", "matricule", autoCreateTables: true);
var membership = (SimpleMembershipProvider)Membership.Provider;
model.motDePasse = membership.GetUser(superviseur.matricule, false).GetPassword();

This exception appears in the last line :

System.NotSupportedException: Specified method is not supported.

How to deal this?

Note that superviseur.matricule is not the source of the problem.


回答1:


As per MSDN - If EnablePasswordRetrieval in web.config is false, a NotSupportedException exception is thrown.

Check this resource to find out how to set enablePasswordReset in Web.config




回答2:


Checking MSDN for GetPassword shows you that it throws the System.NotSupportedException when "EnablePasswordRetrieval is false."

You can change EnablePasswordRetrieval in your web.config



来源:https://stackoverflow.com/questions/21827196/system-notsupportedexception-specified-method-is-not-supported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!