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

Oskar Berggren oskar.berggren at gmail.com
Wed Nov 9 11:40:43 EST 2011


In Monodevelop, have you had a look at the project options -> Run ->
General, where you can set environment variables used when running
through MD. Just to check to make sure nothing there is overriding
no_proxy for your web app.

/Oskar


2011/11/9 H . <test051102 at hotmail.com>:
> Hi Oscar,
>
> yes, using a command line app everything works fine. The problems are
> restricted to ASP.NET apps.
>
> I did reboot my machine after changing proxy settings, so it shouldn't be a
> problem with inheriting the environment variables between processes.
> Furthermore I used the button "Apply System-Wide" in Ubuntu. I am sure, the
> environment variables are correctly set up as they are available directly on
> the command line. To be able to run xsp2 from the command line I need to
> extend my test web app.
>
>
> Greetings,
> Martin
>
>
>
>> From: oskar.berggren at gmail.com
>> Date: Wed, 9 Nov 2011 14:31:04 +0100
>> Subject: Re: [Mono-dev] Environment.GetEnvironmentVariable() not working
>> in Linux ASP.NET app
>> To: test051102 at hotmail.com
>> CC: mono-devel-list at lists.ximian.com
>>
>> 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