ccook
ccook

Reputation: 5959

Configuration files from referenced class libraries in ASP.NET MVC

I have several class libraries within my MVC application which each have a Settings file with its own configuration file. With each configuration file being App.config, how are these aggregated into one configuration file? Should the settings be placed in web.config? Suggested best practice?

Upvotes: 1

Views: 1436

Answers (1)

AUSteve
AUSteve

Reputation: 3248

When you build each class library you'll notice that the app.config file is copied to the bin\output folder with a name like "myclasslibrary.dll.config". This means that each DLL will have it's own config file each with a unique name. You can just include the *.dll.config files in your website's bin folder along with the DLLs and your settings will be picked up.

You can also combine settings from a library's app.config into the web.config file by adding new <section> declarations inside <configSections>.
This MSDN walkthrough has an example: http://msdn.microsoft.com/en-us/library/ms246220%28VS.80%29.aspx
Then you wont need separate config files.

Upvotes: 2

Related Questions