473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

<appSettings> in another file (not web.config)

Hello,

Since it is possible to put application settings in a file other than
web.config, I was wondering what is the best practice in doing so vs.
putting these settings directly in web.config. My point is that when I
deploy an application, I want to overwrite web.config all the time, because
the contents of this file has a direct impact on the application's overall
behavior. For example, the execution timeout for my app is 60 seconds, and
this is by design, this is what I've decided that fits with the
application's purpose. So I don't want anybody opening the web.config file
and deciding that it's 45 seconds, right ? If I know someone has tampered
with the web.config file, I cannot guarantee that everything is going to
behave well.

So, is it a good thing to consider two kinds of configuration settings : 1.
The global settings (like execution timeout) that are never accessed in
code; 2. The application settings, that are accessed in code. The second
kind behind held in a different file than web.config. So when you deploy you
ask no question and overwrite the existing web.config file, knowing that the
newest web.config file might contain some information that you really want
to have because it is intrinsic to the application's design. The app
settings file remaining unchanged unless it has to be updated.

I don't know if this is clear enough but hey it's friday...

Thanks for anyone trying an answer...!!
Nov 19 '05 #1
3 2471
My experience has been that most times when you try to do something outside
the norm, the design, or the standard, you will regret it and either go back
and change it or wish you could go back and change it. You should use the
web.config file for changeable application settings. If the settings get
changed to invalid or unsupportable values, just validate them in code when
retrieving the values or handle the errors.

If you put your settings in a different file, you will still have the risk
of them being modified outside acceptable parameters so you haven't solved
anything and you have added a coding and maintenance headache that will
outweigh any benefit.

For settings that you don't want changed, such as the execution timeout you
mention in your post, just hard code them - though generally you'll wish you
hadn't done that later as well.

I think the best solution is to use the configuration files as intended,
including machine.config and web.config at various levels of your
application and to protect those files from modification by setting
appropriate permissions and policies.

Just my humble opinion,

DalePres
MCAD, MCDBA, MCSE

"Jeff Robichaud" <jf*********@gmail.com> wrote in message
news:uN**************@TK2MSFTNGP12.phx.gbl...
Hello,

Since it is possible to put application settings in a file other than
web.config, I was wondering what is the best practice in doing so vs.
putting these settings directly in web.config. My point is that when I
deploy an application, I want to overwrite web.config all the time,
because the contents of this file has a direct impact on the application's
overall behavior. For example, the execution timeout for my app is 60
seconds, and this is by design, this is what I've decided that fits with
the application's purpose. So I don't want anybody opening the web.config
file and deciding that it's 45 seconds, right ? If I know someone has
tampered with the web.config file, I cannot guarantee that everything is
going to behave well.

So, is it a good thing to consider two kinds of configuration settings :
1. The global settings (like execution timeout) that are never accessed in
code; 2. The application settings, that are accessed in code. The second
kind behind held in a different file than web.config. So when you deploy
you ask no question and overwrite the existing web.config file, knowing
that the newest web.config file might contain some information that you
really want to have because it is intrinsic to the application's design.
The app settings file remaining unchanged unless it has to be updated.

I don't know if this is clear enough but hey it's friday...

Thanks for anyone trying an answer...!!

Nov 19 '05 #2
We've use this approach at my work for over a year and it's worked
well. The benefit is that you can version your settings for each
environment. I respectfully disagree with Dale - putting app settings
in a separate file is supported in web.config:
<appSettings file="config\prod.config" />

This allows you to put your application specific settings into separate
files within a config folder - dev.config, qa.config, and prod.config
for example. You can check the current version of all your config files
into VSS or whatever source control system you use. Then your
web.config should be as close as possible between all environments
(although system.web settings usually prevent them from being exact
copies).

One thing to keep in mind is that the web application will
automatically restart when web.config is updated, but will not detect
changes to referenced files like prod.config. You need to edit the
web.config (add a space or something) to update the app settings for
the application.

- Jon
http://weblogs.asp.net/jgalloway

Nov 19 '05 #3
Interesting point. I wasn't aware of the "appSettings file =" setting. It
allows you to accomplish the same thing in separate files and provide a
cleaner and more readable solution.

DalePres

"jongalloway" <jo*********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
We've use this approach at my work for over a year and it's worked
well. The benefit is that you can version your settings for each
environment. I respectfully disagree with Dale - putting app settings
in a separate file is supported in web.config:
<appSettings file="config\prod.config" />

This allows you to put your application specific settings into separate
files within a config folder - dev.config, qa.config, and prod.config
for example. You can check the current version of all your config files
into VSS or whatever source control system you use. Then your
web.config should be as close as possible between all environments
(although system.web settings usually prevent them from being exact
copies).

One thing to keep in mind is that the web application will
automatically restart when web.config is updated, but will not detect
changes to referenced files like prod.config. You need to edit the
web.config (add a space or something) to update the app settings for
the application.

- Jon
http://weblogs.asp.net/jgalloway

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kenneth | last post by:
Hi, In web.config I have an appsettings: <appSettings> <add key="constring" value="Server=localhost;UID=sa;PWD=secret;Database=myDB" /> </appSettings> This is for my developing machine.
4
by: Jiho Han | last post by:
I have the following defined in web.config under <configuration> node: <system.diagnostics> <switches> <add name="MainSwitch" value="4"/> </switches>
1
by: Shark Bait | last post by:
Hi, I have a web site that I am creating locally on my workstation's "C" drive. I have a reference in my web.config to a resource file (it contains global keys) using "\" as the root. Everything...
1
by: Morten71 | last post by:
in web.config in my dot net 1.1 web projects I have my connection strings in the appSettings section. I usually overruled values by referencing an external config file holding my devsettings like...
9
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it programatically possible in VB.NET to read the contents of web.config's <customErrorselement? I looked at using ConfigurationSettings.AppSettings, but that doesn't work. I need to...
9
by: Milsnips | last post by:
Hi all. i'm tryng to implement the Rewrite.NET url rewritining functionality into a test project i've created, however i am hitting a problem at this line (direct from the web example): ...
2
by: MikeB | last post by:
Hello All, how can I set my selectparameter to a constant value within my constants class or to a value in my web.config file?
5
by: Osamede Zhang | last post by:
I just can't understand what appSettings means, how it work thanks for your read osamede
0
by: Curtin1060 | last post by:
Hi, I have a simple exe.config issue where I'd like to swap out the config file with NAnt/XMLPOKE. I just can't figure out the correct xpath to get to the "file=" attribute. I want to swap in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.