web config - Where should connection strings be stored in a n-tier asp.net application -
folks,
i have asp.net project pretty n-tier, namespace, need separate 3 projects: data layer, middle tier , front end.
i doing because...
a) seems right thing do, and
b) having sorts of problems running unit tests asp.net hosted assemblies.
anyway, question is, keep config info?
right now, example, middle tier classes (which uses linq sql) automatically pull connection string information web.config when instantiating new data context.
if data layer in project can/should using web.config configuration info?
if so, how unit test, (typically in separate assembly) provide soch configuration info?
thank time!
we keep them in global "settings" file happens xml. file contains global settings, 1 of connection string pointing appropriate server username , password. then, when applications consume it, put specific catalog (database) need in connection string.
we have version of file each operating environment (prod, dev, staging, etc). then, 2 settings -- file path (with token representing environment) , environment -- can pick correct settings files.
this has nice benefit of 30 second failover. simple change server name in settings file , restart applications (web) , have failed on (of course have restore data if necessary).
then when application starts, write correct connection string web.config file (if different). this, can change website dev prod changing 1 appsettings value.
Comments
Post a Comment