[Mono-dev] Environment.GetEnvironmentVariable() not working in Linux ASP.NET app
oskar.berggren at gmail.com
Wed Nov 9 06:38:20 EST 2011
2011/11/9 H . <test051102 at hotmail.com>:
> Hi Robert,
> I didn't know that Linux hides certain environment variables from a process
> depending on the identity it is running in. I guess that the only choice for
It doesn't, not as such. Environment variables are inherently per
process, and this is the same in Windows. When a process is launched
it generally inherits the environment variables from its parent, with
any requested modifications.
Then it boils down to how are environment variables configured
administratively for a particular system? The concept of system-wide
and per-user environment variables is an abstraction built on the
above facility, and there is no fundamental requirement for that (e.g.
it would be possibly to build a system where they are set and applied
per executable name, or something entirely different).
In Windows there is a control panel app to set them per user or
system-wide. In Linux each distro may have different methods, but
basically any "system-wide" environment settings will be stored in
e.g. /etc/environment, and it then becomes the responsibility of a few
"core" processes to read and apply these settings to themselves during
e.g. login. "Regular" applications launched by the user will then
Concerning proxy settings with Ubuntu 10.04 as example: These are in
System->Preferences->Network Proxy. These are by default per user
(since it's under Preferences, not Administration). However, the
button "Apply System-Wide" is provided. Clicking that then gives me:
oskar$ cat /etc/environment
oskar$ sudo su - www-data
www-data$ printenv|grep -i prox
Notice how the proxy is applied also for the www-data user. However,
to make the web server see the change it would have to be restarted.
Possibly a reboot is the easiest way to ensure they are re-read.
> platform indepent ASP.NET apps is then to configure proxy settings via
> web.config. Alternatively, it is possible to set the WebClient object's
> Proxy property to null in case no proxies should be used. This is most
> likely valid in intranet environments. The current Mono/master supports both
> of these methods.
> Best regards,
>> To: mono-devel-list at lists.ximian.com
>> From: robertj at gmx.net
>> Date: Sat, 5 Nov 2011 11:47:51 +0100
>> Subject: Re: [Mono-dev] Environment.GetEnvironmentVariable() not working
>> in Linux ASP.NET app
>> Hi Martin,
>> On 05.11.2011 09:48, H . wrote:
>> > Hi Robert,
>> > I am using XSP2& MonoDevelop to debug.
>> You have to restart your user session if you've changed
>> the proxy settings. Being environment-based, these settings
>> won't propagate to running processes.
>> > Based on the answers I think that it might be a Linux related issue.
>> > I have implemented extensive proxy support for WebClient and it's
>> > underlying classes in Mono/master. This code is based on the no_proxy
>> > environment variable in Linux. The question is, how can we obtain the
>> > list of proxies to bypass in Linux? Is there a consistend way to do
>> > this for standard Linux apps AND Linux ASP.NET apps?
>> There is no standard regarding proxy configuration besides
>> those two environment variables "http_proxy" and "no_proxy".
>> Tools that make use of proxies (wget, curl, browsers) may
>> have other proprietary configurations, but at the and they
>> all support these environment variables.
>> > Best regards, Martin
>> >> To: mono-devel-list at lists.ximian.com From: robertj at gmx.net Date:
>> >> Thu, 3 Nov 2011 15:47:37 +0100 Subject: Re: [Mono-dev]
>> >> Environment.GetEnvironmentVariable() not working in Linux ASP.NET
>> >> app
>> >> On 03.11.2011 14:12, H . wrote:
>> >>> Hi Robert,
>> >>> thanks for your hints.
>> >>> The link sent describes how environment variables can be set up
>> >>> in Ubuntu. Of course, nobody would try to manually set up
>> >>> environment variables when trying to configure proxies. This is
>> >>> done by using System>Settings>Network Proxy. After that, Ubuntu
>> >>> sets up the necessary environment variables. In case of the
>> >>> no_proxy environment variable this can be tested by issuing "echo
>> >>> $no_proxy" on the command line.
>> >> Yes, you may see it on *your* own command line, as a normal user,
>> >> but the web server (you didn't specify which one, so we can't
>> >> help) may have its own environment default settings.
>> >> A common way to solve that (if Ubuntu's config tools don't provide
>> >> a facility to set either global or web server specific vars) is to
>> >> set this env var globally and manually.
>> >> Robert
>> >> _______________________________________________ Mono-devel-list
>> >> mailing list Mono-devel-list at lists.ximian.com
>> >> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>> > _______________________________________________ Mono-devel-list
>> > mailing list Mono-devel-list at lists.ximian.com
>> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list