473,473 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Appropriate way of dealing with settings in my app?

In classic ASP I used to have a file called settings.asp included on every
page of my web, it consisted of a number of different settings unique to
this application, among them the database path etc.
I used to set some of the values contidional to which server executed the
script (see listing below). This way I could download the files, edit and
test run them locally, then put them back on the production server again
without having to worry about changing the paths each time.

My question now is: What would be the appropriate way of dealing with this
in .net?

/ Linda

-- partial content of settings.asp --

'--- Locally--------------------
If InStr(Request.ServerVariables("SERVER_NAME"), "mydevserver") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=D:\inetpub\wwwroot\customer\db\survey.mdb;"
BASE_URL = "http://mydevserver/customer/survey/"
FILE_FOLDER = "/files/"
'--- In production--------------
ElseIf InStr(Request.ServerVariables("SERVER_NAME"),
"customerserver.com") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=E:\webhotel\customers\customerserver.com\db\su rvey.mdb;"
BASE_URL = "http://www.customerserver.com/survey"
FILE_FOLDER = "/virtualfiledir/"
End If
Nov 19 '05 #1
19 1752
Hi Linda,

Use the app settings section in your web.config file:

<appSettings>
<add key="FileFolder" value="/foo" />
</appSettings>
You can read the settings with a little bit of code:
string fileFolder =
ConfigurationSettings.AppSettings["FileFolder"];

And you can pull environment specific settings into an external file
and reference the file from web.config:

<appSettings file="devsettings.config"/>

Where devsettings.config would contain an <appSettings> element.

http://odetocode.com/Articles/345.aspx

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/
On Fri, 18 Mar 2005 16:25:25 +0100, "Linda"
<linda(at)ordinarystar.com> wrote:
In classic ASP I used to have a file called settings.asp included on every
page of my web, it consisted of a number of different settings unique to
this application, among them the database path etc.
I used to set some of the values contidional to which server executed the
script (see listing below). This way I could download the files, edit and
test run them locally, then put them back on the production server again
without having to worry about changing the paths each time.

My question now is: What would be the appropriate way of dealing with this
in .net?

/ Linda

-- partial content of settings.asp --

'--- Locally--------------------
If InStr(Request.ServerVariables("SERVER_NAME"), "mydevserver") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=D:\inetpub\wwwroot\customer\db\survey.mdb;"
BASE_URL = "http://mydevserver/customer/survey/"
FILE_FOLDER = "/files/"
'--- In production--------------
ElseIf InStr(Request.ServerVariables("SERVER_NAME"),
"customerserver.com") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=E:\webhotel\customers\customerserver.com\db\s urvey.mdb;"
BASE_URL = "http://www.customerserver.com/survey"
FILE_FOLDER = "/virtualfiledir/"
End If


Nov 19 '05 #2
In web.config you can use the <appSettings> section to store your custom
application settings (note that it's case sensitive):

<configuration>
<appSettings>
<add key="SomeKey" value="SomeValue" />
</appSettings>
</configuration>

Then in you app:

string val = System.Configuration.ConfigurationSettings.AppSett ings["SomeKey"];
// use val here....

-Brock
DevelopMentor
http://staff.develop.com/ballen
In classic ASP I used to have a file called settings.asp included on
every
page of my web, it consisted of a number of different settings unique
to
this application, among them the database path etc.
I used to set some of the values contidional to which server executed
the
script (see listing below). This way I could download the files, edit
and
test run them locally, then put them back on the production server
again
without having to worry about changing the paths each time.
My question now is: What would be the appropriate way of dealing with
this in .net?

/ Linda


Nov 19 '05 #3
Set all the constants/properties in a class file which
you compile to an assembly and place in the /bin
directory of your application.

It's easy to call any constant/property from that .dll

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Linda" <linda(at)ordinarystar.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
In classic ASP I used to have a file called settings.asp included on every
page of my web, it consisted of a number of different settings unique to
this application, among them the database path etc. I used to set some of the values contidional to which server executed the
script (see listing below). This way I could download the files, edit and
test run them locally, then put them back on the production server again
without having to worry about changing the paths each time.

My question now is: What would be the appropriate way of dealing with this
in .net?

/ Linda -- partial content of settings.asp --

'--- Locally--------------------
If InStr(Request.ServerVariables("SERVER_NAME"), "mydevserver") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=D:\inetpub\wwwroot\customer\db\survey.mdb;"
BASE_URL = "http://mydevserver/customer/survey/"
FILE_FOLDER = "/files/"
'--- In production--------------
ElseIf InStr(Request.ServerVariables("SERVER_NAME"),
"customerserver.com") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=E:\webhotel\customers\customerserver.com\db\su rvey.mdb;"
BASE_URL = "http://www.customerserver.com/survey"
FILE_FOLDER = "/virtualfiledir/"
End If

Nov 19 '05 #4
You guys are quick, thanks!!

I have looked briefly into the world of app settings before, and it solves
most of my problem, at least as long as I am the only developer involved.
But at some point there will be other developers, designers etc involved,
who have the bad habit of always downloading/uploading the entire app, of
course resulting in the exact same files in both (or all) locations.
Is there a way to solve that, other than educating my co-workers ;)
Is there a way to force the use of different app setting-files for different
locations. Or maybe it is posible to refer to an app setting file in a
directory outside of the actual application folder, where those co-workers
would never think to look?

/ Linda

"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:4q********************************@4ax.com...
Hi Linda,

Use the app settings section in your web.config file:

<appSettings>
<add key="FileFolder" value="/foo" />
</appSettings>
You can read the settings with a little bit of code:
string fileFolder =
ConfigurationSettings.AppSettings["FileFolder"];

And you can pull environment specific settings into an external file
and reference the file from web.config:

<appSettings file="devsettings.config"/>

Where devsettings.config would contain an <appSettings> element.

http://odetocode.com/Articles/345.aspx

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/
On Fri, 18 Mar 2005 16:25:25 +0100, "Linda"
<linda(at)ordinarystar.com> wrote:
In classic ASP I used to have a file called settings.asp included on everypage of my web, it consisted of a number of different settings unique to
this application, among them the database path etc.
I used to set some of the values contidional to which server executed the
script (see listing below). This way I could download the files, edit and
test run them locally, then put them back on the production server again
without having to worry about changing the paths each time.

My question now is: What would be the appropriate way of dealing with thisin .net?

/ Linda

-- partial content of settings.asp --

'--- Locally--------------------
If InStr(Request.ServerVariables("SERVER_NAME"), "mydevserver") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=D:\inetpub\wwwroot\customer\db\survey.mdb;"
BASE_URL = "http://mydevserver/customer/survey/"
FILE_FOLDER = "/files/"
'--- In production--------------
ElseIf InStr(Request.ServerVariables("SERVER_NAME"),
"customerserver.com") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=E:\webhotel\customers\customerserver.com\db\s urvey.mdb;"
BASE_URL = "http://www.customerserver.com/survey"
FILE_FOLDER = "/virtualfiledir/"
End If

Nov 19 '05 #5
I have a sample of building your own custom configuration sections which
uses the XmlSerializer. This is a very common technique in v1.x:

http://staff.develop.com/ballen/samp...nfigSample.zip

-Brock
DevelopMentor
http://staff.develop.com/ballen
You guys are quick, thanks!!

I have looked briefly into the world of app settings before, and it
solves
most of my problem, at least as long as I am the only developer
involved.
But at some point there will be other developers, designers etc
involved,
who have the bad habit of always downloading/uploading the entire app,
of
course resulting in the exact same files in both (or all) locations.
Is there a way to solve that, other than educating my co-workers ;)
Is there a way to force the use of different app setting-files for
different
locations. Or maybe it is posible to refer to an app setting file in a
directory outside of the actual application folder, where those
co-workers
would never think to look?
/ Linda

"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:4q********************************@4ax.com...
Hi Linda,

Use the app settings section in your web.config file:

<appSettings>
<add key="FileFolder" value="/foo" />
</appSettings>
You can read the settings with a little bit of code: string
fileFolder = ConfigurationSettings.AppSettings["FileFolder"];

And you can pull environment specific settings into an external file
and reference the file from web.config:

<appSettings file="devsettings.config"/>

Where devsettings.config would contain an <appSettings> element.

http://odetocode.com/Articles/345.aspx

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/
On Fri, 18 Mar 2005 16:25:25 +0100, "Linda"
<linda(at)ordinarystar.com> wrote:
In classic ASP I used to have a file called settings.asp included on
every
page of my web, it consisted of a number of different settings
unique to
this application, among them the database path etc.
I used to set some of the values contidional to which server
executed the
script (see listing below). This way I could download the files,
edit and
test run them locally, then put them back on the production server
again
without having to worry about changing the paths each time.
My question now is: What would be the appropriate way of dealing
with
this
in .net?

/ Linda

-- partial content of settings.asp --

'--- Locally--------------------
If InStr(Request.ServerVariables("SERVER_NAME"), "mydevserver") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=D:\inetpub\wwwroot\customer\db\survey.mdb;"
BASE_URL = "http://mydevserver/customer/survey/"
FILE_FOLDER = "/files/"
'--- In production--------------
ElseIf InStr(Request.ServerVariables("SERVER_NAME"),
"customerserver.com") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=E:\webhotel\customers\customerserver.com\db\su rvey.mdb;"
BASE_URL = "http://www.customerserver.com/survey"
FILE_FOLDER = "/virtualfiledir/"
End If


Nov 19 '05 #6
I agree with both schools of thought (web.config and class). There are uses
for both. For example, you can only store text data in the web.config. You
can store objects in a class. On the other hand, the web.config is read into
memory and remains memory-resident for the life of the app. A class can have
static methods that don't require instantiation, but often will require
instantiation. So, keep in mind what your options are, and use the
appropriate method.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:OV**************@TK2MSFTNGP15.phx.gbl...
Set all the constants/properties in a class file which
you compile to an assembly and place in the /bin
directory of your application.

It's easy to call any constant/property from that .dll

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Linda" <linda(at)ordinarystar.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
In classic ASP I used to have a file called settings.asp included on
every
page of my web, it consisted of a number of different settings unique to
this application, among them the database path etc.

I used to set some of the values contidional to which server executed the
script (see listing below). This way I could download the files, edit and
test run them locally, then put them back on the production server again
without having to worry about changing the paths each time.

My question now is: What would be the appropriate way of dealing with
this
in .net?

/ Linda

-- partial content of settings.asp --

'--- Locally--------------------
If InStr(Request.ServerVariables("SERVER_NAME"), "mydevserver") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=D:\inetpub\wwwroot\customer\db\survey.mdb;"
BASE_URL = "http://mydevserver/customer/survey/"
FILE_FOLDER = "/files/"
'--- In production--------------
ElseIf InStr(Request.ServerVariables("SERVER_NAME"),
"customerserver.com") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=E:\webhotel\customers\customerserver.com\db\su rvey.mdb;"
BASE_URL = "http://www.customerserver.com/survey"
FILE_FOLDER = "/virtualfiledir/"
End If


Nov 19 '05 #7
JV
One way might be to encapsulate it into a Web User control. They are easy
to make though they don't have much visual representation at design time.
In your case that's no big deal.

Also, keep in mind that straight ASP techniques generally still work in
ASP.NET. They just might be the "old way" of doing things.

You could perhaps put a script block into each web form. They look
something like:

<script language=C# runat=server>
(code here)
</script>

You might try using the "src" attribute to refer to your asp include file.
I've never tried combining "runat=server" with a "src" attribute, but I
imagine it should work.

-jv
"Linda" <linda(at)ordinarystar.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
In classic ASP I used to have a file called settings.asp included on every
page of my web, it consisted of a number of different settings unique to
this application, among them the database path etc.
I used to set some of the values contidional to which server executed the
script (see listing below). This way I could download the files, edit and
test run them locally, then put them back on the production server again
without having to worry about changing the paths each time.

My question now is: What would be the appropriate way of dealing with this
in .net?

/ Linda

Nov 19 '05 #8
JV
Actually, now that I reread your post, I would recommend putting the
settings in your WEB.CONFIG file and using the folllowing collection object
to retrieve them in each page:

System.Configuration.ConfigurationSettings.AppSett ings

Search for "Introduction to Dynamic Properties" in the online help for
details.
"Linda" <linda(at)ordinarystar.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
In classic ASP I used to have a file called settings.asp included on every
page of my web, it consisted of a number of different settings unique to
this application, among them the database path etc.
I used to set some of the values contidional to which server executed the
script (see listing below). This way I could download the files, edit and
test run them locally, then put them back on the production server again
without having to worry about changing the paths each time.

My question now is: What would be the appropriate way of dealing with this
in .net?

/ Linda

-- partial content of settings.asp --

'--- Locally--------------------
If InStr(Request.ServerVariables("SERVER_NAME"), "mydevserver") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=D:\inetpub\wwwroot\customer\db\survey.mdb;"
BASE_URL = "http://mydevserver/customer/survey/"
FILE_FOLDER = "/files/"
'--- In production--------------
ElseIf InStr(Request.ServerVariables("SERVER_NAME"),
"customerserver.com") Then
DBPATH = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=E:\webhotel\customers\customerserver.com\db\su rvey.mdb;"
BASE_URL = "http://www.customerserver.com/survey"
FILE_FOLDER = "/virtualfiledir/"
End If

Nov 19 '05 #9
A couple of options occur off the top of my head:

a) configure your team's FTP software to ignore "web.config" files
(Dreamweaver does it with "cloaking", NAnt and other tools with
regular expressions of some sort)

b) if your deployments are to known servers with predictable and
stable URLs, you could hard code the settings into an assembly (dll)
with a static accessor that does some sort of switching on the current
URL.

b.1) depending on how complicated your configuration is, you may even
draft an Interface and then derive an actual configuration class for
each deployment.

then again, these 'b' options may result in deploying lots of extra
code with each setup, so a simpler solution, depending on your
toolset, would be 'a'. :-)

David.
Nov 19 '05 #10
Linda (at) wrote:
My question now is: What would be the appropriate way of dealing with this in .net?


I'm surprised that nobody here has mentioned the Registry. ASP.NET Web
Applications are software, running in a Windows environment. The
Registry is intended as a place for software to store configuration
data.

You will be deploying your project on a number of development, test and
production servers. Each of which could be pointed at its own Database
Server, document repository, etc. If you hardcode these settings into
a web.config file in your project, you will have to A) leave them out
of source control, B) trick your deploy script into not moving .config
files, or C) hand edit them each time you deploy. Any of these is a
recipe for disaster. Sooner or later, one of your junior devs will
inadvertantly push his local copy of web.config, and suddenly you'll
find the production site pointed at your development database.

With your configuration settings in the registry, you need only set the
box up once. Set it to point at its target database, and forget it.

As to compiling settings into a class? Yikes!!! As in you need to
recompile the project just to flip the database from Test to
Production??? No thanks!

Jason
http://www.expatsoftware.com

Nov 19 '05 #11
> I'm surprised that nobody here has mentioned the Registry. ASP.NET
Web Applications are software, running in a Windows environment. The
Registry is intended as a place for software to store configuration
data.


Actually the registry isn't a great place for daemon software like IIS and
ASP.NET for three reasons: 1) The worker process for ASP.NET runs under an
identity whose profile isn't fully loaded, therefore HKEY_CURRENT_USER isn't
available and 2) Since HKEY_CURRENT_USER isn't available then you'd need
to have greater permissions to write to HKEY_LOCAL_MACHINE and for security
reasons we don't want this. 3) It difficult to have the admin configure this
because you'd need to have the app running. But if the app requires the settings
to be configured prior to running then how do you configure them? It's sort
of a chicken and the egg problem...

-Brock
DevelopMentor
http://staff.develop.com/ballen

Nov 19 '05 #12
re:
I'm surprised that nobody here has mentioned the Registry.
Accessing the Registry is a fairly slow process.

While fine when checking to see if a user is a registered
user of an WinForms app or a Win32 application,
unless you have proof to the contrary, it seems that
checking a Registry seeting is going to have an adverse
effect on your web application's performance.

re: As to compiling settings into a class? Yikes!!! As in you
need to recompile the project just to flip the database
from Test to Production?
I don't know what "database" you're talking about.

Maybe we are talking about different scenarios.

If you are "testing" a Web app, you compile it as a "Debug"
application and, if you are deploying your application after it
has been debugged, then you'd compile it as a "Release" application.

If you know how to change from a "Debug" environment
to a "Release" environment without recompiling, please let
us know how that can be done.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"jasonkester" <ja*********@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com... Linda (at) wrote:
My question now is: What would be the appropriate way of dealing with

this
in .net?


I'm surprised that nobody here has mentioned the Registry. ASP.NET Web
Applications are software, running in a Windows environment. The
Registry is intended as a place for software to store configuration
data.

You will be deploying your project on a number of development, test and
production servers. Each of which could be pointed at its own Database
Server, document repository, etc. If you hardcode these settings into
a web.config file in your project, you will have to A) leave them out
of source control, B) trick your deploy script into not moving .config
files, or C) hand edit them each time you deploy. Any of these is a
recipe for disaster. Sooner or later, one of your junior devs will
inadvertantly push his local copy of web.config, and suddenly you'll
find the production site pointed at your development database.

With your configuration settings in the registry, you need only set the
box up once. Set it to point at its target database, and forget it.

As to compiling settings into a class? Yikes!!! As in you need to
recompile the project just to flip the database from Test to
Production??? No thanks!

Jason
http://www.expatsoftware.com

Nov 19 '05 #13
Juan T. Llibre wrote:

Accessing the Registry is a fairly slow process.
Indeed. But if you use a static constructor for your
ConnectionFactory, you only need to read from it once per IISRESET.

As to compiling settings into a class? Yikes!!! As in you
need to recompile the project just to flip the database
from Test to Production?


I don't know what "database" you're talking about.

Maybe we are talking about different scenarios.

Database Server. Sorry if I was vague. You do all your development on
one database server, all your testing on another, and host your
production data on a third. The original poster was asking how to
manage the fact that your web application will need to use separate
connection strings in each of these three environments.

If you are "testing" a Web app, you compile it as a "Debug"
application and, if you are deploying your application after it
has been debugged, then you'd compile it as a "Release" application.


I beg to differ. If you are developing and debugging a web app, you
use "Debug". Once you throw it over the wall into Test, you want it to
be a Release build, since it will go on to Production if it passes QA.

It sounds like your release process involves recompiling a bunch of
configuration changes into your .dll, flipping it to Release, and
throwing it live, untested. You should probably talk this over with
your QA department. I bet they'll have some words for you!
Jason
http://www.expatsoftware.com

Nov 19 '05 #14
Brock Allen wrote:
Actually the registry isn't a great place for daemon software like IIS and ASP.NET for three reasons[...]
Since HKEY_CURRENT_USER isn't available then you'd need
to have greater permissions to write to HKEY_LOCAL_MACHINE and for security reasons we don't want this.
Writing configuration data? Remember, we're talking about READING
configuration data here. As in, using the Registry as an alternative
to reading connection strings and such from web.config. So yeah, of
course you'll want to stash things under HKEY_LOCAL_MACHINE. You'll
also want to avoid reading it with every page load, but that's what
static constructors are for.

3) It difficult to have the admin configure this
because you'd need to have the app running.
The Admin will only need to configure this when he is building the box.
Install Windows, Install IIS, run the .REG, and you're good to go
indefinately.

But if the app requires the settings
to be configured prior to running then how do you configure them? It's sort of a chicken and the egg problem...


We must be talking about different things. Again, this is read-only
stuff that would otherwise be found in web.config. You're not saying
you have applications that modify their own web.config at runtime, are
you?

Jason
http://www.expatsoftware.com

Nov 19 '05 #15
re:
If you are "testing" a Web app, you compile it as a "Debug"
application and, if you are deploying your application after it
has been debugged, then you'd compile it as a "Release" application.
I beg to differ. If you are developing and debugging a web app, you
use "Debug". Once you throw it over the wall into Test, you want it to
be a Release build, since it will go on to Production if it passes QA.
Does that mean that, if it *doesn't* pass QA,
it goes back to the "Debug" stage ?

Or, will you continue to "test" new code in Release build mode ?

You have a penchant for semantic hair-splitting.
That's OK, though.

I have a feeling it's the same thought-process which prompted
you to hair-split on the Registry-read process being slower, too.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"jasonkester" <ja*********@gmail.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com... Juan T. Llibre wrote:

Accessing the Registry is a fairly slow process.


Indeed. But if you use a static constructor for your
ConnectionFactory, you only need to read from it once per IISRESET.


> As to compiling settings into a class? Yikes!!! As in you
> need to recompile the project just to flip the database
> from Test to Production?


I don't know what "database" you're talking about.

Maybe we are talking about different scenarios.

Database Server. Sorry if I was vague. You do all your development on
one database server, all your testing on another, and host your
production data on a third. The original poster was asking how to
manage the fact that your web application will need to use separate
connection strings in each of these three environments.

If you are "testing" a Web app, you compile it as a "Debug"
application and, if you are deploying your application after it
has been debugged, then you'd compile it as a "Release" application.


I beg to differ. If you are developing and debugging a web app, you
use "Debug". Once you throw it over the wall into Test, you want it to
be a Release build, since it will go on to Production if it passes QA.

It sounds like your release process involves recompiling a bunch of
configuration changes into your .dll, flipping it to Release, and
throwing it live, untested. You should probably talk this over with
your QA department. I bet they'll have some words for you!

Nov 19 '05 #16
re:
Install Windows, Install IIS, run the .REG,
and you're good to go indefinately.
Until the slightest configuration change
requires that you modify the Windows Registry again.

Why introduce a complexity level which isn't *required* ?

Web.config is a perfectly good place for app settings.

If you're skittish about privacy, an assembly is *also*
a perfectly good place to place app settings.

Taking an application's settings outside an application's
AppDomain introduces retrieval/writing problems which
might be a severe application handicap down the road.

While for Windows Apps registry settings are a good idea,
for ASP.NET web applications they are unneeded and unwanted.

ASP.NET was developed, partly, to get *away* from
having to deal with Registry settings. Why go back now ?


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"jasonkester" <ja*********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com... Brock Allen wrote:
Actually the registry isn't a great place for daemon software like

IIS and
ASP.NET for three reasons[...]
Since HKEY_CURRENT_USER isn't available then you'd need
to have greater permissions to write to HKEY_LOCAL_MACHINE and for

security
reasons we don't want this.


Writing configuration data? Remember, we're talking about READING
configuration data here. As in, using the Registry as an alternative
to reading connection strings and such from web.config. So yeah, of
course you'll want to stash things under HKEY_LOCAL_MACHINE. You'll
also want to avoid reading it with every page load, but that's what
static constructors are for.

3) It difficult to have the admin configure this
because you'd need to have the app running.


The Admin will only need to configure this when he is building the box.
Install Windows, Install IIS, run the .REG, and you're good to go
indefinately.

But if the app requires the settings
to be configured prior to running then how do you configure them?

It's sort
of a chicken and the egg problem...


We must be talking about different things. Again, this is read-only
stuff that would otherwise be found in web.config. You're not saying
you have applications that modify their own web.config at runtime, are
you?

Jason
http://www.expatsoftware.com

Nov 19 '05 #17
Juan T. Llibre wrote:
re:
Install Windows, Install IIS, run the .REG,
and you're good to go indefinately.


Until the slightest configuration change
requires that you modify the Windows Registry again.

I think we're using different definitions of "Configuration". I'm
talking about SERVER configuration. As in, "I am the Production
WebServer. I point at a database server named DB_LIVE." This is
information that must be set up once per box, and will never change.

Perhaps you are talking Application configuration. As in,
"HomePage=/index.aspx", "SomeAppGlobal=6", etc. This is information
that gets pushed out with every build, to every box. And yes, I'd
agree that it should be compiled into a .dll.

The nice thing about keeping your Server Configuration out of
web.config (or anything in the project) is that it's hard to
accidentily overwrite it. We've all worked with junior devs. This is
my safeguard against getting called in on a Saturday night to roll back
their mistakes.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #18
Alright, after seeing your replies to Juan, I see what you're getting at
here. Sure, the registry would work for the things you're talking about.
But nothing says you can't make web.config read-only via DACLs. Neither one
is impervious to Junior Engineer Jimmy[1], though. My only question is why
go against the grain when the .config model is obviously the preferred method
in ASP.NET and the CLR? How would you then configure several different application
on the same machine? Or even several different sites? Not that you couldn't
with the registry, of course. It's only software, so anything's possible.
It's just that with the .config model those sorts of issues are non-issues.

As for the perf of reading, again, the existing model already caches these
settings in memory so it's unnecessary for you to build your own caching
mechanism. Or your own reload mechanism once the settings are changed. It's
myopic to think that settings never change, BTW.

I think your point of view is obviously a strong one based upon personal
experience, so if it works for your environment then that's great. There's
nothing wrong with it but I don't see enough compelling reasons in it to
recommend it to other people as a necessarily superior technique.

-Brock
DevelopMentor
http://staff.develop.com/ballen

[1] Apologies to Mike Woodring [http://www.bearcanyon.com] (he's not Jimmy,
BTW)
Brock Allen wrote:
Actually the registry isn't a great place for daemon software like

IIS and
ASP.NET for three reasons[...]
Since HKEY_CURRENT_USER isn't available then you'd need
to have greater permissions to write to HKEY_LOCAL_MACHINE and for

security
reasons we don't want this.

Writing configuration data? Remember, we're talking about READING
configuration data here. As in, using the Registry as an alternative
to reading connection strings and such from web.config. So yeah, of
course you'll want to stash things under HKEY_LOCAL_MACHINE. You'll
also want to avoid reading it with every page load, but that's what
static constructors are for.
3) It difficult to have the admin configure this
because you'd need to have the app running.

The Admin will only need to configure this when he is building the
box.
Install Windows, Install IIS, run the .REG, and you're good to go
indefinately.
But if the app requires the settings
to be configured prior to running then how do you configure them?

It's sort
of a chicken and the egg problem...

We must be talking about different things. Again, this is read-only
stuff that would otherwise be found in web.config. You're not saying
you have applications that modify their own web.config at runtime, are
you?

Jason http://www.expatsoftware.com


Nov 19 '05 #19
re:
I think we're using different definitions of "Configuration".
Indeed, we are.

re: The nice thing about keeping your Server Configuration
out of web.config...is that it's hard to accidentily overwrite it.
Normally, whatever server configuration is allowable, from within
the .NET Framework, is taken care of at the machine.config level,
not at the web.config level.

As a Server Admin, you can set things up so that sensitive
machine.config settings cannot be overwritten by junior users.

Junior users shouldn't be developing
at the web server console, anyway. ;-)

Although, in your particular development environment, writing
to the Registry simply works, I'd hesitate before making that
the preferred method of setting server-wide settings.

We left ASP for ASP.NET so that
we wouldn't have to deal with the Registry.

I wouldn't recommend going back to it,
though it might work for you.


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"jasonkester" <ja*********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... Juan T. Llibre wrote:
re:
> Install Windows, Install IIS, run the .REG,
> and you're good to go indefinately.


Until the slightest configuration change
requires that you modify the Windows Registry again.

I think we're using different definitions of "Configuration". I'm
talking about SERVER configuration. As in, "I am the Production
WebServer. I point at a database server named DB_LIVE." This is
information that must be set up once per box, and will never change.

Perhaps you are talking Application configuration. As in,
"HomePage=/index.aspx", "SomeAppGlobal=6", etc. This is information
that gets pushed out with every build, to every box. And yes, I'd
agree that it should be compiled into a .dll.

The nice thing about keeping your Server Configuration out of
web.config (or anything in the project) is that it's hard to
accidentily overwrite it. We've all worked with junior devs. This is
my safeguard against getting called in on a Saturday night to roll back
their mistakes.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #20

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

Similar topics

5
by: Tom Willis | last post by:
How are the expert pythoneers dealing with config files? Is there anything similair to .net's config files or java's .properties? A quick search on google didn't return anything that looked...
3
by: Michael J. Hudson | last post by:
I'm not sure what good attaching a stylesheet to a Microsoft Word document does. When you save the document as an HTML file, Word throws in all of its style and font settings into the HTML file...
1
by: Igor Kramarsich - EDIT | last post by:
I'm having problems dealing with dates in my queries/SQL code. I need a search digit date. In form define date field without format I receive results. But I go to define date filed with short date...
8
by: Lenn | last post by:
Hello, Just some background: I'm developing an application that basically executes series of tasks. So far I have 2 group of tasks run on different threads (2 different threads). Which run in...
1
by: SenthilVel | last post by:
Hi I am in the Process of conversion of my existing 1.1 Dotnet Code to 2.0 framework. for each project when i compile in VS2005 , i get this error\warning: Use command line option...
4
by: SenthilVel | last post by:
Hi I am in the Process of conversion of my existing 1.1 Dotnet Code to 2.0 framework. for each project when i compile in VS2005 , i get this error\warning: Use command line option...
1
by: Nathan Sokalski | last post by:
I am trying to test out an ASP.NET web service I wrote, but the Add Web Reference dialog gives me the following errors: The proxy settings on this computer are not configured correctly for web...
4
by: RP | last post by:
I am using SQL Server 2005 as backend. I have a Text Box that accepts Date in the format dd-MM-yyyy. But when I attempt to insert a record, an error is displayed: Cannot convert char to DateTime...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: Programs dealing with autoruns Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list programs that help me to view/modify the autoruns...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.