We're a small team, working on a asp.net web project, as well as service, both projects dependent on a shared class library.
We'd like to have the class library settings different per developer (and later on for production). In settings are included sensitive information, such as passwords, as well as hostnames.
How should we assign these settings ?
Unless I'm wrong, web.config/application settings aren't good enough, as they don't work for the shared class library.
ps: Also, some variables should be statically linked, and the rest (such as connectionstrings) should be dynamic.
A configuration file (web. config) is used to manage various settings that define a website. The settings are stored in XML files that are separate from your application code. In this way you can configure settings independently from your code. Generally a website contains a single Web.
A typical location would be: C:\Windows\System32\inetsrv\ApplicationHost. config.
The web.config app.config files are read from whatever website/app your are running. I.E., Any app settings files in the class library are not used. e.g. any references to ConfigurationManager.ConnectionStrings ConfigurationManager.AppSettings within your class library will use whichever web.config/app.config that is defined in the app that is using the class library and not any .config you may have setup within the class library itself.
The easiest way to manage different settings per developer and for production is to have your config stored in a different file e.g.
<appSettings configSource="Web.appSettings.dev.config"/>
Each dev has their own Web.appSettings.dev.config which is not in source control. When in production you just change to:
<appSettings configSource="Web.appSettings.live.config"/>
You just need to make sure you have some kind of template Web.appSettings.template.config in svn that is the master but does not have any settings in it and manually manage making sure any new keys or connection strings that are added to the template also get added to each devs file and the production file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With