Social Icons

Monday, 25 February 2013

what is difference between web.config and app.config files in .Net Applications

Difference between Web.Config and App.Config


In this article i will explain what are the differences between web.config and app.config files. What information can we able to store in this configuration files.


These configuration files xml files that can be changed as need by developer. We can say these files are settings files or global files for our applications. Generally these files contains application settings which needs to be available for all of forms in our application. We could store some globally required information here. If we want to use or interact with these files we have to import namespace called System.Configuration(Windows) and System.Web.Configuration(web). Different types of configuration files available in .Net. You can find it in MSDN.  


Web.Config files are purely for web applications.
This file is automatically created when we create new web projects.
we can have many web.config files in web project where each folder can contain single web.config file only.
In this files we can able to store global information which can be accessed based on location of the 
config file. Whenever we change these file automatically website will restart with modified details.


App.Config files are for Windows Application.
This file is not add by default when we create new project. We need to externally add these to file to our project by Right Clicking on project --> Select Add New Item--> Select "Application Configuration file".
Modifying App.Config file will not affect the running application until we restart the application.Only one app.config file is allowed in one project.


Web.Config and App.Config are used for storing global application settings.Check these NameSpaces for more details.System.Configuration(Windows) and System.Web.Configuration(web).


 I would like to have feedback from my blog readers. Your valuable feedback,Suggestions,Questions, Comments about this article are always welcome.


Please Give your Valuable Suggestions,Questions and Comments to improve my blog.