Differences between appsettings and connectionstrings in Web. config
In ASP. NET programming, it is found that you can write the connection data string configuration in two ways, namely, etettings and connectionstrings.
Appsettings is used in the ASP. net1.1 period. In. NET Framework 2.0, connectionstrings is added specifically to get configuration files in the configurationmanager class.
Use the following data in the appsettings and connectionstrings sections:
Using system. configuration;
Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
Label1.text = configurationmanager. connectionstrings ["connectionstringsname"]. tostring ();
Label2.text = configurationmanager. appsettings ["appsettingsname"]. tostring ();
}
}
The difference between <connectionstrings> and <etettings>
1. <connectionstrings>
<Connectionstrings>
<Add name = "connectionstringname" connectionstring = "Data Source = server name; initial catalog = database name; user id = user; Password = password"
Providername = "system. Data. sqlclient"/>
</Connectionstrings>
In <connectionstrings>, You can reference <% $ connectionstring: name %>.
2. <appsettings>:
<Add key = "connectionstringname" value = "Data Source = server name or IP address; initial catalog = database name; persist Security info = false; user id = user; Password = password; packet size = 4096 ">
</Add>