Sunday 17 August 2014

Differentiate between web.config, app.config and machine.config files

Web.config file

  1. web.config is used for ASP.NET Web Projects / Web Services. web.config by default has several configurations required for the web application. It is also called Application Level Configuration File and inherits setting from the machine.config file.
  2. web.config is parsed at runtime, so if you edit the web.config file, the web application will automatically load the changes in the config file.
  3. web.config file is automatically generated when new web application created.
  4. You can have more than one web.config file in your application. Specifically, you can have a web.config for each folder under your web application.
  5. The web.config file is required for ASP.NET webpages.
  6. You can store information like connections strings, domains, application properties,session information, Cookie information,Viewstate information etc in web.config file. 





App.config file
  1. app.config is used for Windows Forms, Windows Services, Console Apps and WPF applications.
  2. app.config is parsed at compile time, so if you edit the app.config file, you have to restart the application. At compile time a copy of the app.config file is taken, renamed to [output].config and moved to the build folder. This copy can then be modified, and your modifications will be read each time the application/service is started.
  3.  app.config is not added automatically to an application. You can go to the solution explorer, select 'Add new item' and add the 'Application Configuration File'.
  4. There is always one app.config file in a window application.
  5. The app.config file is optional in an application and doesn't have to be used when writing desktop applications.


Machine.config file


  1. machine.config file is automatically installed on your system when you install Visual Studio.Net. This is also called Machine Level Configuration File. 
  2. Only one machine.config file exists on a server, and is at the highest level in the configuration hierarchy.
  3. The settings of machine.config file are applied to all the web applications residing on the server.
  4. The machine.config file is overridden by the web.config file.
  5. Without the machine.config file, application can not be executed.
  6. It is a global settings file for all the applications that run on the .Net Framework on the machin.





No comments:

Post a Comment