[Mono-dev] Environment.GetEnvironmentVariable() not working in Linux ASP.NET app

Oskar Berggren oskar.berggren at gmail.com
Wed Nov 9 08:31:04 EST 2011


2011/11/9 H . <test051102 at hotmail.com>:
> Hi Robert,
>
> I have now debugged the issue using Ubuntu Maverick/ 32 bit. I did the
> following:
>
> (1) Configure system proxy settings and reboot machine
> (2) In terminal "echo $http_proxy" returns "http://http.proxy:8080/"; "echo
> $no_proxy" returns "localhost,127.0.0.0/8,*.local"
> (3) Created an ASP.NET project in MonoDevelop and entered the following code
> in Default.aspx.cs
>       protected void Page_Load(object Sender, EventArgs e)
>       {
>              string str1=Environment.GetEnvironmentVariable("http_proxy");
>              string str2=Environment.GetEnvironmentVariable("no_proxy");
>
>              string strBreak="stop";//put breakpoint at this line
>       }
> (4) After pressing F5, we can see that str1 contains it's expected value
> while str2 is null
>
> By the way, I have checked the user name of the mono process. It's the same
> as the currently logged in user and therefore it should have access to all
> environment variables. ASP.NET/Mono seems to have a problem reading the
> no_proxy variable while the http_proxy variable can be accessed as expected.
>
>


Weird. I just did a quick test using command line program, and this
prints the correct information when run using F5 in Monodevelop, on
Mono 2.6.7.

public static void Main(string[] args)
{
            Console.WriteLine(
Environment.GetEnvironmentVariable("http_proxy"));
          Console.WriteLine(  Environment.GetEnvironmentVariable("no_proxy"));
}


If you try this code both when run through Monodevelop, and when
compiled and run manually from the command line, is there a
difference?

If you move your code to Application_Start in global.asax, is there a
difference? (Long shot...)

/Oskar


More information about the Mono-devel-list mailing list