RSS Feed

ASP.NET Configuration with web.config file

November 2, 2011 by Sourabh Sharma

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.

    1. They are never locked: you can update the web.config settings at any point even your application is running.
    2. 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.
    3. 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.

  1. <appSettings> section: This section allows us to add our own miscellaneous pieces of information.
  2. <connectionString> sections: this section allows us to define the connection information for accessing a database.
  3. <system.web> section: This section holds every ASP.NET setting we will need to configure.


No Comments »

No comments yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>