Overriding AspNetSqlMembershipProvider in ASP.NET 4.0

by rbellantoni 11/8/2011 7:45:00 AM

If you are having as much trouble as I did figuring out where the hell all the web.config settings went after creating Users and Roles using the built in administration tools in .NET then read on!

It turns out, that in ASP.NET 4.0, they removed some of the "clutter" from the web.config since some web.configs were getting very large with configurations and developer added keys etc. So they moved it to a machine.Config file inside of the framework folder. What this means is that they took out all the standard settings in the web.config that are required to run a website so you don't have to see them anymore....HOWEVER, they ALSO moved the default membership provider settings as well. So what does this mean?  It means you can't just make a tweak to the default settings, you need to actually implement your OWN web.config provider as follows:

                <!--<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" 
                 enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"
 passwordAttemptWindow="10" applicationName="/"/>-->
                <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" 
connectionStringName="test" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="500" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
                <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
                <add name="DisplayName"/>
        <roleManager enabled="true">
                <add connectionStringName="test" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider"/>
                <!--<add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider"/>-->
                <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider"/>

Now you can go ahead and change the settings as necessary.


.NET | ASP.NET Enterprise Library | SQL SERVER

Powered by BlogEngine.NET
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail


<<  October 2018  >>

View posts in large calendar

Recent comments



The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2018

Sign in