Hello Everyone,
I am trying to use a custom role provider, the main purpose so that I don't have to use a database file. My web.config file is posted below. My problem is that I think I have followed all the steps to create a custom role provider using both articles on MSDN and some written by Scott Gu. After Modifying my web.config file I went to the asp.net configuration to test the connection. Users are created in the remote database but roles are being picked up and created in the App_Data folder. Can anyone give me a hint at what I am doing wrong? thanks in advance.
<?
xmlversion="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\Framework\v2.x\Config
-->
<
configurationxmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"><
appSettings/><
connectionStrings><
addname="MyConnectionString"connectionString="Data Source=10.10.10.10;Database=MyDataBase;Persist Security Info=True;User ID=user;Password=password"providerName="System.Data.SqlClient"/></
connectionStrings><
system.web><!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
--><
roleManagerenabled="true"/><
membershipdefaultProvider="CustomSQLRoleManager"><
providers><
clear/><
addname="CustomSQLRoleManager"type="System.Web.Security.SqlMembershipProvider"connectionStringName="MyConnectionString"applicationName="MyAppllicationName"minRequiredPasswordLength="6"minRequiredNonalphanumericCharacters="0"requiresQuestionAndAnswer="false"requiresUniqueEmail="true"/></
providers></
membership><
compilationdebug="true"><
assemblies><
addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/><
addassembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation><!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
--><
authenticationmode="Forms"/><!--
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="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
--></
system.web></
configuration>Ok. I figured out what I was missing and bolded the lines that I added to my web.config file
<?
xmlversion="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\Framework\v2.x\Config
-->
<
configurationxmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"><
appSettings/><
connectionStrings><
removename="LocalSqlServer"/><
addname="MyConnectionString"connectionString="Data Source=10.10.10.10;Database=MyDatabase;Persist Security Info=True;User ID=User;Password=password"providerName="System.Data.SqlClient"/></
connectionStrings><
system.web><!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
--><
roleManagerenabled="true"defaultProvider="CustomSQLRoleManager"><
providers><
clear /><
addconnectionStringName="MyConnectionString"applicationName="MyApp"name="CustomSQLRoleManager"type="System.Web.Security.SQLRoleProvider" /></
providers></
roleManager>
<
membershipdefaultProvider="SQLRoleManager"><
providers><
clear/><
addname="SQLRoleManager"type="System.Web.Security.SqlMembershipProvider"connectionStringName="MyConnectionString"applicationName="MyApp"minRequiredPasswordLength="6"minRequiredNonalphanumericCharacters="0"requiresQuestionAndAnswer="false"requiresUniqueEmail="true"/></
providers></
membership><
compilationdebug="true"><
assemblies><
addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/><
addassembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation><!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
--><
authenticationmode="Forms"/><!--
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="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
--></
system.web></
configuration>|||Ok. I figured out what I was missing and bolded the lines that I added to my web.config file
<?
xmlversion="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\Framework\v2.x\Config
-->
<
configurationxmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"><
appSettings/><
connectionStrings><
removename="LocalSqlServer"/><
addname="MyConnectionString"connectionString="Data Source=10.10.10.10;Database=MyDatabase;Persist Security Info=True;User ID=User;Password=password"providerName="System.Data.SqlClient"/></
connectionStrings><
system.web><!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
--><
roleManagerenabled="true"defaultProvider="CustomSQLRoleManager"><
providers><
clear /><
addconnectionStringName="MyConnectionString"applicationName="MyApp"name="CustomSQLRoleManager"type="System.Web.Security.SQLRoleProvider" /></
providers></
roleManager>
<
membershipdefaultProvider="SQLRoleManager"><
providers><
clear/><
addname="SQLRoleManager"type="System.Web.Security.SqlMembershipProvider"connectionStringName="MyConnectionString"applicationName="MyApp"minRequiredPasswordLength="6"minRequiredNonalphanumericCharacters="0"requiresQuestionAndAnswer="false"requiresUniqueEmail="true"/></
providers></
membership><
compilationdebug="true"><
assemblies><
addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/><
addassembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation><!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
--><
authenticationmode="Forms"/><!--
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="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
--></
system.web></
configuration>
No comments:
Post a Comment