How best to determine if running in a development, test, or production mode?

  • Thread starter Thread starter David
  • Start date Start date
D

David

I want to develop a single web app that will be run in three
environments: development, test, and production. The test and prodc.
will be on the same machine under different directories. I wish to
have same type of file, configuration string, etc. in the root
directory of each environment to tell the program where it is running.
I will use this to determine what connection string, sql, etc. to use.

Currently, I am using 3 different WEB_CONFIG files. but this is a pain
to keep in sync and I live in fear of copying the wrong one to
production!

I tried merging two appending files into WEB_CONFIG file,
"<appSettings file="xxx"/>, but this does not work.

Should one place some control file in the root directory and use the
"erver.MapPath("/");" command to get the path for the file.

Also, I have very limited control over the testing/prod machine so I
can not make any larger system level change without permissions from
the evil web master!!!

Thoughts?

Thanks
 
you can reference an external configuration file that will be automatically
merged at run time, by using the appsettings node. If the external file is
present, ASP.NET will combine the appSettings values from web.config with
those in the external file. If a key/value pair is present in both files,
ASP.NET will use the value from the external file. e.g.

<appSettings file="dev_settings.config"/>

Cathal
 
Can one Merge two appsettings files? I tried and got an error. Eg.
one for the specific environment and one for the general settings.
 
Back
Top