Search code examples
c#asp.netweb-configasp.net-membershipsqlmembershipprovider

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:

  • The first Provider has Name=="AspNetSqlMembershipProvider" and RequiresQuestionAndAnswer==true
  • The second Provider has Name=="MyServer" and RequiresQuestionAndAnswer==false.

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


Solution

  • 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.