简体   繁体   中英

Specified method is not supported. with method MembershipUser.GetPassword()

I get the following error:

Server Error in '/' Application.

Specified method is not supported.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Specified method is not >supported.

Source Error:

Line 109:            modelo.apellido = usuario.apellido;
Line 110:            modelo.nombre = usuario.nombre;
-->Line 111:         modelo.clave = Membership.GetUser(usuario.userName).GetPassword();<--
Line 112:
Line 113:            return PartialView(modelo);

This is my Web.Config:

<membership defaultProvider="SimpleMembershipProvider">
  <providers>
    <clear/>
    <add name="SimpleMembershipProvider"
         type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData"
         connectionStringName="DefaultConnection" 
         enablePasswordRetrieval="true" 
         enablePasswordReset="true" 
         passwordFormat="Encrypted"
         requiresQuestionAndAnswer="false" 
         requiresUniqueEmail="true" 
         maxInvalidPasswordAttempts="5" 
         minRequiredPasswordLength="6" 
         minRequiredNonalphanumericCharacters="0" 
         passwordAttemptWindow="10" 
         applicationName="/"/>
  </providers>
</membership>

<roleManager enabled="true" defaultProvider="SimpleRoleProvider">
  <providers>
    <add name="SimpleRoleProvider" 
         type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData" 
         connectionStringName="DefaultConnection" 
         applicationName="/" />
  </providers>
</roleManager>

I tried this but when I debug, the enablePasswordRetrieval property of the Membership class is set to "false".

Thanks.

Try this :

MembershipUser u = Membership.GetUser(usuario.userName, false);
modelo.clave = u.GetPassword();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM