Best way for app to determine what server it is on and customize config info?

K

Ken Fine

I would like to be able to move my ASP.NET applications to any of a number
of servers without changing code.

My apps do a lot of disk I/O and in some cases I might be specifying absoute
drive mappings for whatever bad reason. This will break if apps are
arbitrarily copied around.

I imagine I could centralize a bunch of configurations in web.config. If my
apps could reliably (and efficiently) identify what server they were running
off of, they could pick out the right settings for a particular server. This
need extends beyond the rather trivial example of drive mappings.

Can someone suggest a good way or ways?

Thanks,
-KF
 
S

Steven Cheng[MSFT]

Hi Ken,

From your description, you have developed an ASP.NET web application and
since your application will have many disk I/O accessing operations in the
application(which seriouly coupled with the machine's physical disk, path
structure), you're wondering a flexible way to make your application avoid
changing when deploy over different servers, correct?

Based on my experience, for ASP.NET application(or other .net
applications) that will deal with some machine specific (or changable)
things, it is a good practice to store those changable info in application
configuration file. Thus, we can modify and customize the configuration
file whenever deploy to a new server box.

For your scenario, you mentioned that

=============
If my apps could reliably (and efficiently) identify what server they were
running off of, they could pick out the right settings for a particular
server.
=============

would you give some further explanation on this? Do you mean you need to
programmtically get the current machine's name or you want the server
configuratino info of the current machine? .NET's built-in class
"System.Environment" has provide some static members give us some data of
the current machine(such as MachineName and SpecialFolders...). For other
machine specific info, you may use WMI interface to query some certain info
you want.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Ken Fine

Thanks, this was exactly what I was looking for, Steven. All I need is some
simple key for what machine is what, and System.Environment will tell me
that. Appreciate it.

-KF
 
S

Steven Cheng[MSFT]

My pleasure :)

Regards,

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
 

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,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top