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

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
 
C

Cathal Connolly [C# MVP]

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
 
D

David

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top