C#: Reading MembershipSection from Web.config

K

Kbalz

I need to read values from the Web.Config xml file, particularly the
<Membership> Section. Using asp.net 2.0, C#.

I'm writing a custom membership provider.. I've set up a class that
inherets from MembershipProvier, and all of the override methods have
been started.. but for instanace in the EnabledPasswordReset method, I
want the return value to be read from the config section
enablePasswordReset..

I see dozens of examples explaining how to read from the appSettings
section, or ConnectionString settings.. but zero examples pulling
values from the membership section in C#. I'd rather have these values
in the xml file rather than returning the value in the class methods
directly.

For instance: my membership section looks like this

<configuration> .. <system.web> ..
<membership defaultProvider="MembershipProvider">
<providers>
<add connectionStringName="ConnectionString"
applicationName="secure2"
enablePasswordReset="false" ****
passwordFormat="Hashed"
minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"
name="MembershipProvider"
type="secure.auth._auth"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true" />
</providers>
</membership>
... </system.web> ..</configuration>

And in secure.auth._auth, the other ride methods reside.. here is one:

public override bool EnablePasswordReset
{
get { throw new Exception("The method or operation is not
implemented."); }
}

I'd like this method to return "false" in this case, because the method
reads the line in the config snippet from above where the **** are
located.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top