How to change an ASP.NET toolkit connection string

How can I change the name of the ASP.NET toolkit connection string? (Which connection string will the ASP.NET configuration tool use) I learn ASP.NET everywhere, and in the book I'm reading right now, the connection string is: LocalSqlServer.

I want to use my local sql server database instead of sql express to store roles, memberships and other data.

I used aspnet_regsql.exe to create the required data structures in my database. after that I changed my web.config as follows:

<connectionStrings> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString="Server=(LOCAL); Database=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings>

but when I run the ASP.NET configuration tool, it says that: "The connection name" ApplicationServices "was not found in the application configuration or the connection string is empty."

The ASP.NET configuration tool uses a connection string named: ApplicationServices, not LocalSqlServer.

the reason is that I need to change web.config: <connectionStrings> <add name="ApplicationServices" connectionString="Server=(LOCAL); Database=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings>

and everything is working fine.

I want to know why the hell my site uses a connection string with the name: ApplicationServices and all books and online documentation uses LocalSqlServer? and how to change it to LocalSqlServer?

I have: Windows 7 Sql Server 2008 R2 Visual Studio 2010 Premium Project Type - Website

+4
source share
1 answer

I accidentally found the answer to my question when searching for the web.config file.

if you override the default machine.config configuration settings in the web.config file, you can change the name of the ASP.NET toolkit connection string.

I got my web.config file from the book code archive, and that was the problem.

in web.config u can override which connection string name will be used for: membership, profile and roleManager.

To cancel the use of membership:
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/"/>
</providers>
</membership>

where connectionStringName is the name of the connection string that will be used to store membership information.

others:

<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="LocalSqlServer"
applicationName="/"/>
</providers>
</profile>

and

<roleManager enabled="true">
<providers>
<clear />
<add connectionStringName="LocalSqlServer" applicationName="/"
name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
<add applicationName="/" name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>

+15
source

Source: https://habr.com/ru/post/1334896/


All Articles