What is web config file in .NET Framework?

Asked 05-Jul-2021
Viewed 325 times


What is Web config file and state with example? How to create web config file in .NET Framework?

1 Answer


Web.config file
 In the c# programming develop the many types of application like window application, console application, web application, and etc. web.config file mainly build in web application for website configuration (connection string, URL mapping, and any configuration on website store in web.config file). This web.config file is mainly one copy built in web application file if we want to build the many file then we can build it but not in root folder because in root folder build only one config file , we can build many config file in web application, we must make sub folder and then this config file build in sub folder.
 This web.config file in a xml file means than web.config file extension in .xml, we need not restart the web server, when the settings change in the configuration file, asp.net automatically detect the changes in the configuration file. In this configuration many type of settings store in this file.
 For example
• Database connection
• Cache settings
• Cookie setting
• Session settings
• Error handling
• Security

Example of web.config file
<?xml version='1.0'?>
  For more information on how to configure your ASP.NET application, please visit
      <compilation debug='true' targetFramework='4.5' />
      <httpRuntime targetFramework='4.5' />
How to create web.config file
1. Web.config file already exist in project when we are create the project. In some time doesn’t exits then then goto Solution Explorer, and click the Refresh button automatically create the web.config file, if already exits then update the setting
2. In solution explorer right click on project name and add new item
3. In the template window click the web configuration file
4. And click the Add to create the file and open for editing