web.config is used with web applications. web.config will by default have several configurations required for the web application. You can have a web.config for each folder under your web application.
app.config is used for windows applications. When you build the application in vs.net, it will be automatically renamed to <appname>.exe.config and this file has to be delivered along with your application.
You can use the same method to call the appsettings values from both config files :
When I add a connection string by wizard in a WebApp , the wizard add the
connection string to web.config like
<add name="MyDataBase" connectionString="Data Source=.\SQLEXPRESS;Initial
But if I add the same connection string by wizard in a class library
project, the connection string in app.config will be:
connectionString="Data Source=.\SLEEPERS;Initial Catalog=xxxx...
The connection string name in app.config will be initial with
Why have the difference between web.config and app.config
app config-->This app settings is used for windows based application,suppose if you are creating windows based application in vb.net you have to set the database setting in app settings
web.config-->This web settings is used for web based application,suppose if you are creating web based application in asp.net you have to set the database setting in wen settings
by Ezzaral: Snipped "fake sig" link. Please restrict such links to your site-wide user signature, which can be edited from the user control panel.
Don't forget that the machine.config file exists, which is your global config for .NET, most commonly referenced in ASP.NET literature, as the global settings used in IIS for ALL ASP.NET apps on that server. The only time you ever really want to alter this file is if your running on a custom web server and want to change your global .NET settings. Messing with this file is a very BAD idea.
Also, App.Config in an application is optional, it doesn't have to be used when writing desktop apps.