Breaking News

LightBlog

Saturday 19 March 2016

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

Introduction:

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.

Description:

In previous articles I explained validate email address using  Dropdownlist validation in Asp.net Using RequiredField validator  In ASP.Net And Many Article Relating to Validation Now I Will   Explained  differences between web.config and app.config files  In Asp.net.

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:

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:

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.

Conclusion:

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).