urig
urig

Reputation: 16841

requiresQuestionAndAnswer set to false in web.config but RequiresQuestionAndAnswer is true at runtime

In an ASP.net web application I have defined the following Membership provider in the web.config:

<membership>
  <providers>
    <add connectionStringName="MyServer" name="MyServer" type="System.Web.Security.SqlMembershipProvider" 
      enablePasswordReset="true" 
      requiresQuestionAndAnswer="false" 
      enablePasswordRetrieval="false" />
  </providers>
</membership>

When I run the application in the debugger, the property Membership.Provider.RequiresQuestionAndAnswer is true.

Why? And how can I fix this?

Update: Ar tuntime, the Membership.Providers collection contains two instances of Provider that are almost identical. The differences are:

Now trying to figure out where the first one is coming from.

Upvotes: 5

Views: 1121

Answers (2)

Ken Egozi
Ken Egozi

Reputation: 1835

Per the follow up question, the mystery providers is defined on a lower level config file, named machine.config, which is the server-wide parent config file for all asp.net sites running on the machine. See some more details at the MSDN page for asp.net config hierarchy.

Upvotes: 3

urig
urig

Reputation: 16841

The fix for my problem is to specify in web.config:

<membership defaultProvider="MyServer>

The reason why there's an "extra" Provider at run-time is that it's defined in my machine.config file. Here's how to find yours.

Credit for fix goes to @meidan-alon and credit for root cause goes to @ken-egozi :)

Upvotes: 0

Related Questions