Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put ApplicaitonSettings in a layered mvc project?

I've got a basic asp.net MVC project that has a Web project, a Service dll project and a Data dll project. I started to store config values in the web project's applicaiton settings but I've come across a few instances where I need them in the service layer. The only way I can think of sharing the values is to pass them to the service layer via parameters. Is there any other way of having one config value that is accessible to all projects?

like image 236
NullReference Avatar asked Feb 23 '23 06:02

NullReference


1 Answers

I tend to keep config tied to the outermost layer (where it is defined in app.config or web.config) and have that layer explicitly pass through any values which are needed for domain or infrastructure logic, which should be what your lower level layers contain.

I find the notion of having config values contained in the outer layer which are 'magically' used by lower level layers to be rather non-intuitive and opaque.

like image 128
Adam Ralph Avatar answered Mar 15 '23 04:03

Adam Ralph