While developing web application in ASP.NET. For many reasons we need to configure our application. These reasons may be security or anythinf else. In this article I will tell you about the website configuration. and what are the advantages for configure the website. Later in this article i will tell you about the web.config file and the main sections of this web.config file.
ASP.NET Configuration
Every ASP.NET website includes a web.config file to configure the fundamental settings. Here I will tell you that why website configuration is very helpful for your website. There are following advantages of using ASP.NET Configuration files.
- They are never locked: you can update the web.config settings at any point even your application is running.
- They are easily accessed and replicated: you can change and access the web.config file from a remote computer. You can also copy them and use it to apply identical settings.
- The settings are easy to edit and understand: the settings in the web.config file are human readable which means they can be edited and understood without needing a special configuration tool.
web.config file:
The web.config file uses a predefined XML format. The web.config file is case-sensitive. The entire content of the file is nested in a rootelement. The basic structure of web.config file is as following:-
<?xml version=”1.0”?>
<configuration>
<configSections>………..</ configSections>
<appSettings>…………….</ appSettings>
<connectionStrings>……………</ connectionStrings>
<system.web>…………….</ system.web>
<system.codedom>…………</ system.codedom>
<system.webServer>…………</ system.webServer>
</configuration>
There are three sections in the web.config file that you all work with.
- <appSettings> section: This section allows us to add our own miscellaneous pieces of information.
- <connectionString> sections: this section allows us to define the connection information for accessing a database.
- <system.web> section: This section holds every ASP.NET setting we will need to configure.