Where to use connection string?

Posted by Subramanyame under Interview Questions on 12/26/2012 | Points: 10 | Views : 1100 | Status : [Member] | Replies : 6
Hi,


What is the main difference between writing connection string in app.config and web.config?

Thanks in advance.




Responses

Posted by: Sheonarayan on: 12/26/2012 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
App.config file is used in the Desktop application (Windows forms or WPF or class library).

Web.config file is used in the web projects (web site or web application)

If you have written a connection string in app.config file and using that project (class library) in web application or website, you need to keep the same connection string into the web.config file as the IIS server reads only web.config file for the settings data.

Hope this helps.

Thanks


Regards,
Sheo Narayan
http://www.dotnetfunda.com

Subramanyame, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/27/2012 [Member] Bronze | Points: 25

Up
0
Down
you will find app.config in windows applications.

you will find web.config in asp.net web application

Thanks
Pavan Kumar
Mark Answer if this fits the need

Subramanyame, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 12/27/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
App.config is the default config file in either a desktop application or a class library project.
web.config is the default config file in a website project and website application project.
This is discussed here:
http://www.c-sharpcorner.com/Forums/Thread/49897/

Please Mark As Answer if this helps you.

.

Subramanyame, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Elephant12 on: 1/3/2013 [Member] Starter | Points: 25

Up
0
Down
app.config file stores information for windows application and web.config file stores data for web application.

Subramanyame, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 1/3/2013 [Member] Starter | Points: 25

Up
0
Down
app.config for windows application
web.config for web application

Subramanyame, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sarithapraveen on: 1/29/2013 [Member] Starter | Points: 25

Up
0
Down
app.config is the config file in desktop application and web.config is the config file in
web application.

Subramanyame, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response