amol
amol

Reputation: 1607

Why connection string is necessary to keep in main web app and in data access project in asp.net mvc

I am creating a N-Tier ASP.Net MVC application where I am having a Data access layer in which I have stored connection string in App.config file. I have another project as web application where I am using services to fetch records from database, when I run the web application I got the error of connection string to resolve that I put connection string in web.config file. I am confused, Why it is necessary to have connection string at multiple places (Web project and Data access layer project)

Upvotes: 2

Views: 102

Answers (1)

Chris Pratt
Chris Pratt

Reputation: 239400

This is a common misconception. Configuration belongs to the application. When your app is compiled/published, the DAL gets rolled in as a DLL. Any config you had in that particular project does not apply. The only thing that matters is the config in the project that's actually deployed. In truth, if you've got something like a class library, then having an App.config or whatever is basically pointless, anyways. It's never going to be used.

Just put your connection string in your Web.config.

Upvotes: 2

Related Questions