All about web.config configuration files
Posted by RAJU K, Last modified by RAJU K on 13 December 2012 11:24 PM
What is web.config?
Web.config is the main settings and configuration file for an ASP.NET web application. The file is an XML document that defines configuration information regarding the web application.This file stores the information about how the web application will act.
The web.config file contains information that controls module loading, security configuration, session state configuration, and application language and compilation settings. Web.config files can also contain application specific items such as database connection strings.
Note: When you modify the settings in the Web.Config file, you do not need to restart the Web service for the modifications to take effect.. By default, the Web.Config file applies to all the pages in the current directory and its subdirectories.
What can be stored in Web.config file?
There are number of important settings that can be stored in the configuration file. Here are some of the most frequently used configurations, stored conveniently inside Web.config file..
1. Database connections.
2. Session States
3. Error Handling (CustomError Page Settings.)
4. Security (Authentication modes)
What is the best place to store Database connection string?
In Web.Config, you would add a key to the AppSettings Section:
<add key="MyDBConnection" value="data source=<ServerName>;Initial catalog =<DBName>;user id=<Username>;password=<Password>;" />
<add key="ConnectionString" value= "data source=localhost;Initial catalog=northwind;user id=sa;password=mypass" />
Then, in your ASP.Net application - just refer to it like this:
string connectionString = (string )ConfigurationSettings.AppSettings["ConnectionString"];
Please check following links for more information on data base connection strings.
How to Edit / Upload the Web.config for your website?
Caution: Before making any modifications to your web.config make sure you create a viable backup of your site that can be restored should the edits create a problem.In a default installation, your web.config file is located in the httpdocs folder. If file extensions are not listed, it may just appear as web. Visual Studio is the program we recommend using when modifying the web.config. However, if it is not installed on your local machine, you can Notepad to make changes to the web.config file.
Options for Accessing Your Web.config
Use FTP to Download, Modify, and then Upload the Web.config File Back to the Server
Use Plesk 11.x to Access and Modify the Web.Config File
Use Plesk 9.x to Access and Modify the Web.Config File
Please open help pdesk ticket when you get into trouble.