Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Web.config and environment variables. Please help!

Reply
Thread Tools

Web.config and environment variables. Please help!

 
 
=?Utf-8?B?b3R0bw==?=
Guest
Posts: n/a
 
      05-12-2006
Hi, all:
I would like to know one thing: Is it possible to access an environment
variable (like PATH) from web.config file? Something like this:
<appSettings>
<add key="name" value="%Environment{PATH}\Shared"></add>
</appSettings>

or

<add key="name" value="${PATH}\Shared"></add>
or anything else?

I think itÂīs not possible the access to system or environment variables from
inside web.config, but I need to be absolutely sure.

Thanks a lot for your help!
 
Reply With Quote
 
 
 
 
Greg Young
Guest
Posts: n/a
 
      05-12-2006
No, you would have to translate these in your code that read in the value.

Cheers,

Greg Young
MVP - C#
"otto" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, all:
> I would like to know one thing: Is it possible to access an environment
> variable (like PATH) from web.config file? Something like this:
> <appSettings>
> <add key="name" value="%Environment{PATH}\Shared"></add>
> </appSettings>
>
> or
>
> <add key="name" value="${PATH}\Shared"></add>
> or anything else?
>
> I think itīs not possible the access to system or environment variables
> from
> inside web.config, but I need to be absolutely sure.
>
> Thanks a lot for your help!



 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      05-12-2006
"otto" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> I think itīs not possible the access to system or environment variables
> from
> inside web.config, but I need to be absolutely sure.
>
> Thanks a lot for your help!



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      05-12-2006
"otto" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> I think itīs not possible the access to system or environment variables
> from
> inside web.config, but I need to be absolutely sure.


It's not possible

(Sorry for the empty post previously...)


 
Reply With Quote
 
Karl Seguin [MVP]
Guest
Posts: n/a
 
      05-12-2006
No.

But what you can do is encapsulate that logic inside a function:

public sealed ConfigurationManager
{
private ConfigurationManager(){}
public static string Path
{
get
{
return Configuration.AppSettings["name"].Replace("{PATH}",
Environment.GetEnvironmentVariable("Path");
}
}
}

as an example...

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


"otto" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, all:
> I would like to know one thing: Is it possible to access an environment
> variable (like PATH) from web.config file? Something like this:
> <appSettings>
> <add key="name" value="%Environment{PATH}\Shared"></add>
> </appSettings>
>
> or
>
> <add key="name" value="${PATH}\Shared"></add>
> or anything else?
>
> I think itīs not possible the access to system or environment variables
> from
> inside web.config, but I need to be absolutely sure.
>
> Thanks a lot for your help!



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      05-12-2006
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:(E-Mail Removed)...

> No.
>
> But what you can do is encapsulate that logic inside a function:
>
> public sealed ConfigurationManager
> {
> private ConfigurationManager(){}
> public static string Path
> {
> get
> {
> return Configuration.AppSettings["name"].Replace("{PATH}",
> Environment.GetEnvironmentVariable("Path");
> }
> }
> }
>
> as an example...


Yes of course, but what value does that add? Why not just interrogate the
environment variable when required...?


 
Reply With Quote
 
Karl Seguin [MVP]
Guest
Posts: n/a
 
      05-12-2006
It helps encapsulate the logic. A lot of people would have done the
replacement each time on all of their pages. Apologies with assuming you
didn't know this...you never know what people do and don't know

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


"Mark Rae" <(E-Mail Removed)> wrote in message
news:%23crK%(E-Mail Removed)...
> "Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
> net> wrote in message news:(E-Mail Removed)...
>
>> No.
>>
>> But what you can do is encapsulate that logic inside a function:
>>
>> public sealed ConfigurationManager
>> {
>> private ConfigurationManager(){}
>> public static string Path
>> {
>> get
>> {
>> return Configuration.AppSettings["name"].Replace("{PATH}",
>> Environment.GetEnvironmentVariable("Path");
>> }
>> }
>> }
>>
>> as an example...

>
> Yes of course, but what value does that add? Why not just interrogate the
> environment variable when required...?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
70-284 Lab Environment, Need Virtual Environment brooklynbridge508@hotmail.com MCSA 4 05-02-2007 09:49 AM
Setting an environment variable from another environment variable marcwentink@hotmail.com Java 5 04-04-2007 10:39 PM
PLEASE HELP - How to simulate 'wait' and 'notify' in RMI environment cpptutor2000@yahoo.com Java 2 10-09-2005 04:41 AM
REQ: Please post Sybex - MCSA MCSE - 70-290 291 292 293 294 - Windows Server 2003 Environment Management And Maintenance Study Guide Patrick MCSE 1 11-06-2003 08:39 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments