Change the default connection string for membership, roles, etc.

By default, it seems to me that my web application uses LocalSqlServer as the connection string for any applications like membership / roles / authentication, etc.

Is there any way to change what the default connection string should be? It seems so arbitrary that by default it is "LocalSqlServer", and the only way I could find it was to go for it for about two hours.

I donโ€™t want me to have to call my connection to the LocalSqlServer server, and I have no idea if this is an existing item that I can rewrite.

+7
source share
2 answers

Yes, these connection strings can be set in the web.config file:

Composition

 <membership defaultProvider="SqlMembershipProvider"> <providers> <add name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyMembershipConnectionString" /> </providers> </membership> 

Roles

 <roleManager defaultProvider ="SqlRoleProvider" > <providers> <add name="SqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="MyRolesConnectionString" /> </providers> </roleManager> 

See here for more information: A practical guide. Using ASP.NET Membership Provider

+4
source

2 things. Find or add the connectionStringName property to your membership configuration.

Here is an example that uses it

 <system.web> ... <membership defaultProvider="MembershipADProvider"> <providers> <add name="MembershipADProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="YOUR CONN STRING" connectionUsername="<domainName>\administrator" connectionPassword="password"/> </providers> </membership> ... </system.web> 

And you need to configure the connection of course

 <connectionStrings> <add name="YOUR CONN STRING" connectionString= "[ANY ConnectionSTRIN]" /> </connectionStrings> 
+2
source

All Articles