3
I was looking at Web.confg and would like to know what the <appSettings>
? What it interferes with our application?
3
I was looking at Web.confg and would like to know what the <appSettings>
? What it interferes with our application?
5
Contains custom application settings. This is a predefined configuration section provided by . NET Framework.
<appSettings>
<!-- Elements to add, clear, or remove configuration settings -->
</appSettings>
The element stores custom application configuration information, such as database connection chains, file paths, Web XML service Urls, or any other custom configuration information for an application. The key/value pairs specified in the element are accessed in code using the Configurationsettings class.
You can use the attribute file in the Web element. config and application configuration files. This attribute specifies a configuration file that provides additional settings or replaces the settings specified in the element. The attribute file can be used in source code control team development scenarios, such as when a user wants to replace the specified project settings in an application configuration file. Configuration files specified by attribute file must have a root node at a time .
The following example shows an external application settings file (custom.config) that defines a custom application configuration:
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="MyCustomSetting" value="MyCustomSettingValue" />
</appSettings>
The following example shows an application configuration file that consumes the configuration in the external settings file and sets its own application configuration:
<configuration>
<appSettings file="custom.config">
<add key="ApplicationName" value="MyApplication" />
</appSettings>
</configuration>
This element can be used in the application configuration file, machine configuration file (Machine. config), and Web. config files that are not in the application directory level.
4
The tag <appSettings/>
serves as a container for the specific settings of your application, in which case the settings the developer wants to store.
Example:
<appSettings>
<add key="conf1" value="teste"/>
<appSettings/>
Note that we have added in the tag <appSettings/>
a daughter tag, which corresponds to our configuration. The attributes of <add/>
used were key
and value
, whereas key
sets the configuration name and value
the value it stores.
Source: http://www.linhadecodigo.com.br/artigo/1612/net-entendendo-o-arquivo-webconfig.aspx#ixzz5eqkibPuq
4
In appSettings we can create keys and set values for these keys and, what I think is very good, we don’t need to recompile the application to exchange the value of these keys.
Let’s go to two examples of where to use appSettings:
1- Let’s assume that soon after the approval of the project, your client, decided to exchange the email in which he receives when the application sends. Instead of going to find the variable that we saved his email and exchange it for the new one, in appSettings we switch to the new email and ready.
2- "- Nice John, look at this condition, if item == 45. Why 45???". Of course we will not put everything in appSettings, but it would be much better to understand if the condition was, if item == appSettings["codCarro"]. A basic example!
It’s explained... Now let’s get to work!
Let’s go on our Web.Config to create our keys. It’s extremely simple:
example: http://www.morcegosweb.com/morcegos/arquivos/lightbox/app1.jpg
Read more here so you understand better: http://www.linhadecodigo.com.br/artigo/2209/definicoes-da-aplicacao-appsettings.aspx#ixzz5eqlRvG48
Browser other questions tagged .net configuration web.config app.config
You are not signed in. Login or sign up in order to post.