PasswordReset() throws exception - passwordAnswer?


I have an app that I'm trying to implement the following, but can't seem to figure out how:

  1. User signs up, but the system creates its own temporary password for them
  2. Admin approves user and as part of that approval, the user gets sent a temporary username/password.

The problem is that I can't set the MembershipProvider to enable password retrieval as that seems to disable certficate authentication. I do have passwordReset enabled, but when I try to use it in step 2 (trying to create a new password so I can have it in plaintext to email it to the user), it throws an error:

General Error: System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentNullException: Value cannot be null. Parameter name: passwordAnswer

Is there any way around this?

Here's a code snippet of the relevant code:

MembershipUser mu = Membership.GetUser(Session["UserId"], false);
string password = mu.ResetPassword();
asked on Stack Overflow Apr 15, 2021 by Levi Wallach

2 Answers


The password is null because nothing got entered. In your code, just use an if:

if (passwordAnswer==null){
//do stuff here

While you can write anything there, I recommend, maybe:

if (passwordAnswer==null){
 passwordAnswer=" ";//just a space

If you want it to be a generated password, research on generating random alphanumeric strings.

answered on Stack Overflow Apr 15, 2021 by Cole Henrich

I was able to circumvent this issue by adding requiresQuestionAndAnswer="false" to the membership provider in my web.config:

<membership defaultProvider="DefaultMembershipProvider">


        <add name="DefaultMembershipProvider"
            passwordFormat="Hashed" />


answered on Stack Overflow Apr 16, 2021 by Levi Wallach

User contributions licensed under CC BY-SA 3.0