mugsey
asked on
AspNetSqlMembershipProvider always picking up machine.config settings - not picking up web.config asp.net c#
Dohhhhh
Why is the AspNetSqlMembershipProvide r always picking up machine.config settings and not the web.config settings??? For example I specify
requiresQuestionAndAnswer= "false" in web.config but it always picks up the default setting in machine.config.
Here is my web.config
<section name="Membership" type="System.Web.Security. SqlMembers hipProvide r, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d 50a3a"/>
<section name="MemberShip" type="ExtendedMembership.M emberShipC onfigurati on, ExtendedMembership" allowDefinition="MachineTo Applicatio n"/>
<MemberShip defaultProvider="SqlMember ShipProvid er">
<providers>
<clear/>
<add name="SqlMemberShipProvide r"
type="ExtendedMembership.S qlMemberSh ipProvider , ExtendedMembership"
applicationName="/"
connectionStringName="Loca lSqlServer "
description="Extended MemberShip API"/>
</providers>
</MemberShip>
<Membership>
<providers>
<clear/>
<remove name="AspNetSqlMembershipP rovider" />
<add name="AspNetSqlMembershipP rovider"
type="System.Web.Security. SqlMembers hipProvide r, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d 50a3a"
connectionStringName="Loca lSqlServer "
enablePasswordRetrieval="t rue"
enablePasswordReset="false "
requiresQuestionAndAnswer= "false"
applicationName="/"
requiresUniqueEmail="true"
passwordFormat="clear"
maxInvalidPasswordAttempts ="15"
minRequiredPasswordLength= "1"
minRequiredNonalphanumeric Characters ="0"
passwordAttemptWindow="30"
passwordStrengthRegularExp ression="" />
</providers>
</Membership>
Why is the AspNetSqlMembershipProvide
requiresQuestionAndAnswer=
Here is my web.config
<section name="Membership" type="System.Web.Security.
<section name="MemberShip" type="ExtendedMembership.M
<MemberShip defaultProvider="SqlMember
<providers>
<clear/>
<add name="SqlMemberShipProvide
type="ExtendedMembership.S
applicationName="/"
connectionStringName="Loca
description="Extended MemberShip API"/>
</providers>
</MemberShip>
<Membership>
<providers>
<clear/>
<remove name="AspNetSqlMembershipP
<add name="AspNetSqlMembershipP
type="System.Web.Security.
connectionStringName="Loca
enablePasswordRetrieval="t
enablePasswordReset="false
requiresQuestionAndAnswer=
applicationName="/"
requiresUniqueEmail="true"
passwordFormat="clear"
maxInvalidPasswordAttempts
minRequiredPasswordLength=
minRequiredNonalphanumeric
passwordAttemptWindow="30"
passwordStrengthRegularExp
</providers>
</Membership>
ASKER
Hi here is my full web.config
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Fra mework\v2. x\Config
-->
<configuration>
<configSections>
<sectionGroup name="system.web.extension s" type="System.Web.Configura tion.Syste mWebExtens ionsSectio nGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35">
<sectionGroup name="scripting" type="System.Web.Configura tion.Scrip tingSectio nGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35">
<section name="scriptResourceHandle r" type="System.Web.Configura tion.Scrip tingScript ResourceHa ndlerSecti on, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35" requirePermission="false" allowDefinition="MachineTo Applicatio n"/>
<sectionGroup name="webServices" type="System.Web.Configura tion.Scrip tingWebSer vicesSecti onGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35">
<section name="jsonSerialization" type="System.Web.Configura tion.Scrip tingJsonSe rializatio nSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35" requirePermission="false" allowDefinition="Everywher e"/>
<section name="profileService" type="System.Web.Configura tion.Scrip tingProfil eServiceSe ction, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35" requirePermission="false" allowDefinition="MachineTo Applicatio n"/>
<section name="authenticationServic e" type="System.Web.Configura tion.Scrip tingAuthen ticationSe rviceSecti on, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35" requirePermission="false" allowDefinition="MachineTo Applicatio n"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
<section name="Membership" type="System.Web.Security. SqlMembers hipProvide r, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d 50a3a"/>
<section name="MemberShip" type="ExtendedMembership.M emberShipC onfigurati on, ExtendedMembership" allowDefinition="MachineTo Applicatio n"/>
<section name="dataConfiguration" type="Microsoft.Practices. Enterprise Library.Da ta.Configu ration.Dat abaseSetti ngs, Microsoft.Practices.Enterp riseLibrar y.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
<section name="loggingConfiguration " type="Microsoft.Practices. Enterprise Library.Lo gging.Conf iguration. LoggingSet tings, Microsoft.Practices.Enterp riseLibrar y.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
<section name="exceptionHandling" type="Microsoft.Practices. Enterprise Library.Ex ceptionHan dling.Conf iguration. ExceptionH andlingSet tings, Microsoft.Practices.Enterp riseLibrar y.Exceptio nHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</configSections>
<appSettings/>
<dataConfiguration defaultDatabase="LocalSqlS erver"/>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=XXX;Initial Catalog=XXX;Integrated Security=true;" providerName="System.Data. SqlClient" />
</connectionStrings>
<MemberShip defaultProvider="SqlMember ShipProvid er">
<providers>
<clear/>
<add name="SqlMemberShipProvide r"
type="ExtendedMembership.S qlMemberSh ipProvider , ExtendedMembership"
applicationName="/"
connectionStringName="Loca lSqlServer "
description="Extended MemberShip API"/>
</providers>
</MemberShip>
<Membership>
<providers>
<clear/>
<remove name="AspNetSqlMembershipP rovider" />
<add name="AspNetSqlMembershipP rovider"
type="System.Web.Security. SqlMembers hipProvide r, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d 50a3a"
connectionStringName="Loca lSqlServer "
enablePasswordRetrieval="t rue"
enablePasswordReset="false "
requiresQuestionAndAnswer= "false"
applicationName="/"
requiresUniqueEmail="true"
passwordFormat="clear"
maxInvalidPasswordAttempts ="15"
minRequiredPasswordLength= "1"
minRequiredNonalphanumeric Characters ="0"
passwordAttemptWindow="30"
passwordStrengthRegularExp ression="" />
</providers>
</Membership>
<location path="Reminder.aspx">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
<location path="Register.aspx">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
<system.net>
<mailSettings>
<smtp>
<network host="localhost"/>
</smtp>
</mailSettings>
</system.net>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Exten sions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35"/>
</controls>
</pages>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Se rvices.Scr iptHandler Factory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Se rvices.Scr iptHandler Factory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers. ScriptReso urceHandle r, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers. ScriptModu le, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35"/>
</httpModules>
<roleManager enabled="true" defaultProvider="SqlRoleMa nager">
<providers>
<clear/>
<add name="SqlRoleManager" type="System.Web.Security. SqlRolePro vider" connectionStringName="Loca lSqlServer " applicationName="/"/>
</providers>
</roleManager>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Exten sions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D 50A3A"/>
<add assembly="System.Web.Exten sions.Desi gn, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD3 64E35"/>
<add assembly="System.Windows.F orms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C56193 4E089"/></ assemblies >
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms name=".XXX" loginUrl="login.aspx" defaultUrl="default.aspx"
protection="All" timeout="30" path="/" requireSSL="false"
slidingExpiration="true" enableCrossAppRedirects="f alse"
cookieless="UseDeviceProfi le" domain="">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericEr rorPage.ht m">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm " />
</customErrors>
-->
</system.web>
<system.web.extensions>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
<!--
<jsonSerialization maxJsonLength="500">
<converters>
<add name="ConvertMe" type="Acme.SubAcme.Convert MeTypeConv erter"/>
</converters>
</jsonSerialization>
-->
<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "true|false"/>
-->
<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
writeAccessProperties attributes. -->
<!--
<profileService enabled="true"
readAccessProperties="prop ertyname1, propertyna me2"
writeAccessProperties="pro pertyname1 ,propertyn ame2" />
-->
</webServices>
<!--
<scriptResourceHandler enableCompression="true" enableCaching="true" />
-->
</scripting>
</system.web.extensions>
<system.webServer>
<validation validateIntegratedModeConf iguration= "false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMo de" type="System.Web.Handlers. ScriptModu le, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFac tory-Integ rated"/>
<add name="ScriptHandlerFactory " verb="*" path="*.asmx" preCondition="integratedMo de" type="System.Web.Script.Se rvices.Scr iptHandler Factory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35"/>
<add name="ScriptHandlerFactory AppService s" verb="*" path="*_AppService.axd" preCondition="integratedMo de" type="System.Web.Script.Se rvices.Scr iptHandler Factory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35"/>
<add name="ScriptResource" preCondition="integratedMo de" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers. ScriptReso urceHandle r, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad3 64e35"/>
</handlers>
</system.webServer>
</configuration>
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Fra
-->
<configuration>
<configSections>
<sectionGroup name="system.web.extension
<sectionGroup name="scripting" type="System.Web.Configura
<section name="scriptResourceHandle
<sectionGroup name="webServices" type="System.Web.Configura
<section name="jsonSerialization" type="System.Web.Configura
<section name="profileService" type="System.Web.Configura
<section name="authenticationServic
</sectionGroup>
</sectionGroup>
</sectionGroup>
<section name="Membership" type="System.Web.Security.
<section name="MemberShip" type="ExtendedMembership.M
<section name="dataConfiguration" type="Microsoft.Practices.
<section name="loggingConfiguration
<section name="exceptionHandling" type="Microsoft.Practices.
</configSections>
<appSettings/>
<dataConfiguration defaultDatabase="LocalSqlS
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=XXX;Initial Catalog=XXX;Integrated Security=true;" providerName="System.Data.
</connectionStrings>
<MemberShip defaultProvider="SqlMember
<providers>
<clear/>
<add name="SqlMemberShipProvide
type="ExtendedMembership.S
applicationName="/"
connectionStringName="Loca
description="Extended MemberShip API"/>
</providers>
</MemberShip>
<Membership>
<providers>
<clear/>
<remove name="AspNetSqlMembershipP
<add name="AspNetSqlMembershipP
type="System.Web.Security.
connectionStringName="Loca
enablePasswordRetrieval="t
enablePasswordReset="false
requiresQuestionAndAnswer=
applicationName="/"
requiresUniqueEmail="true"
passwordFormat="clear"
maxInvalidPasswordAttempts
minRequiredPasswordLength=
minRequiredNonalphanumeric
passwordAttemptWindow="30"
passwordStrengthRegularExp
</providers>
</Membership>
<location path="Reminder.aspx">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
<location path="Register.aspx">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
<system.net>
<mailSettings>
<smtp>
<network host="localhost"/>
</smtp>
</mailSettings>
</system.net>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Exten
</controls>
</pages>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Se
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Se
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.
</httpModules>
<roleManager enabled="true" defaultProvider="SqlRoleMa
<providers>
<clear/>
<add name="SqlRoleManager" type="System.Web.Security.
</providers>
</roleManager>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Exten
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D
<add assembly="System.Web.Exten
<add assembly="System.Windows.F
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms name=".XXX" loginUrl="login.aspx" defaultUrl="default.aspx"
protection="All" timeout="30" path="/" requireSSL="false"
slidingExpiration="true" enableCrossAppRedirects="f
cookieless="UseDeviceProfi
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericEr
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm
</customErrors>
-->
</system.web>
<system.web.extensions>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
<!--
<jsonSerialization maxJsonLength="500">
<converters>
<add name="ConvertMe" type="Acme.SubAcme.Convert
</converters>
</jsonSerialization>
-->
<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "true|false"/>
-->
<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
writeAccessProperties attributes. -->
<!--
<profileService enabled="true"
readAccessProperties="prop
writeAccessProperties="pro
-->
</webServices>
<!--
<scriptResourceHandler enableCompression="true" enableCaching="true" />
-->
</scripting>
</system.web.extensions>
<system.webServer>
<validation validateIntegratedModeConf
<modules>
<add name="ScriptModule" preCondition="integratedMo
</modules>
<handlers>
<remove name="WebServiceHandlerFac
<add name="ScriptHandlerFactory
<add name="ScriptHandlerFactory
<add name="ScriptResource" preCondition="integratedMo
</handlers>
</system.webServer>
</configuration>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
But could you download this simple example using custom membership and see if you can set the web.config to it does not ask for password question and answer?
Its here
http://www.code-magazine.com/Article.aspx?quickid=0703071
But could you download this simple example using custom membership and see if you can set the web.config to it does not ask for password question and answer?
Its here
http://www.code-magazine.com/Article.aspx?quickid=0703071
ASKER
THANKS BUT I HAVE SORTED IT - I FOUND OUT THAT MY membership element was not under system.web
http://msdn2.microsoft.com/en-us/library/ms998317.aspx