In this blog I am trying to explain the introduction of configuration files in C#.
Basically all configuration file are use to configure the particular application. In c# web. app file used to configure the setting of particular web application, on the other hand app. config is used to configure the windows application developed in .net, while the machine. config, it is automatically installed when you install.Net Framework. It is installed at Microsoft.NET\Framework\v1.1.4322\CONFIG. It contains default and machine-specific values for all supported setting. And only one machine. config file can exist on a server. Within this blog, many of the C# code examples assume you have both included a reference to System.Configuration.dll in your project.
It 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(behave). The web.config file always 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. Now be comparing how these configurations are differing to each other
web.config vs app.config
1. web.config is used with web applications while app.config is used for windows applications.
2. You can have more than one web.config file in your application. You can have a web.config for each folder under your web application. But there is always one app.config file in a window application.
3. If you make any changes to the web.config, web application will immediately load the changed config. But in case of app.config, you will have to restart the application.
4. web.config file is automatically added to the application while app.config is not automatically added. You can go to the solution explorer and select 'Add new item' and add the 'Application Configuration File'.
The machine configuration file, Machine.config, contains settings that apply to an entire computer. This file is located in the %runtime install path%\Config directory. Machine.config contains configuration settings for machine-wide assembly binding, built-in remoting channels, and ASP.NET.
The configuration system first looks in the machine configuration file for the appSettings and other configuration sections that a developer might want to define. It then looks in the application configuration file. To keep the machine configuration file manageable, it is best to put these settings in the application configuration file. However, putting the settings in the machine configuration file can make your system more maintainable. For example, if you have a third-party component that both your client and server application uses, it is easier to put the settings for that component in one place. In this case, the machine configuration file is the appropriate place for the settings, so you don't have the same settings in two different files.
web.config vs machine.config
1.This is automatically installed when you install. Net Framework.It is installed at Microsoft.NET\Framework\v1.1.4322\CONFIG. It contains default and machnine-specific values for all supported setting.
2. Only one machine.config file can exist on a server.
3. This file is at the highest level in the configuration hierarchy.
4. It’s like a common repository for standard items and it’s over ridden by web.config file.
5. Without the Machine.Config file Application cannot be executed.
1.This is automatically created when you create an ASP.Net web application project.
2.This file inherits the settings from the machine.config and can override them as required.
3.Without the Web.Config file, Application can still be executed.