Connecting Tech Pros Worldwide Forums | Help | Site Map

Rerouting Requests via a Proxy because of .NET "bug"

Codex Twin
Guest
 
Posts: n/a
#1: Nov 21 '05
I am re-sending this in the hope that it might illicit a response. I have a
corporate client who forces their workstations to get the proxy server
details using an automatic proxy discovery script.

Unfortunately, the .NET Framework does not support automatic proxy discovery
scripts. See:
http://support.microsoft.com/default...5BLN%5D;307220

The article above details that the way to workaround this is to edit the
machine.config file. This is impossible for me. Luckily there is a
programmtic way of assigning the proxy settings. The way to do it is
detailed in this article:
http://support.microsoft.com/kb/q318140/

The second article explains how to handle requests when there is a proxy
server between the .NET client and the web service. Unfortunately the
solution only deals with Web Services. The WebService class has a Proxy
property to which an object of type of IWebProxy can be passed - and all is
good.

But in my case, I have an ASP.NET web forms app, not a Web Service. So how
do I try and route my client requests via the Proxy server programmatically?

What I have tried so far is to use an HttpModule which *should* intercept
the request and route it through the Proxy server. In the custom
OnBeginRequest method I have in my HttpModule:

public void OnBeginRequest(object sender, EventArgs e)
{
//************************************************** *********************
WebProxy wp = new WebProxy("http://my.proxy.blah", true);
//************************************************** *********************

HttpRequest req = ((HttpApplication)sender).Request;
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(req.Url.Absolute Uri);
wr.Proxy = wp;

}


However, this doesn't cut it. :-(
The request obviously does not get routed via the proxy server. Can Anyone
tried this before and tell me how to workaround this problem.


Also, does anyone know if the .NET Framework version 2 (or even the version
2 beta) addresses the problem of being able to detect proxy settings using
discovery scripts.
Thanks.
CT





Scott Allen
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Rerouting Requests via a Proxy because of .NET "bug"


Codex:

One way I've worked with proxies is to use the GlobalProxySelection
class:

GlobalProxySelection.Select = new WebProxy("127.0.0.1", 8888);

Hope this work for you too,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 3 Dec 2004 15:41:37 -0000, "Codex Twin" <codex@more.com>
wrote:
[color=blue]
>I am re-sending this in the hope that it might illicit a response. I have a
>corporate client who forces their workstations to get the proxy server
>details using an automatic proxy discovery script.
>
>Unfortunately, the .NET Framework does not support automatic proxy discovery
>scripts. See:
>http://support.microsoft.com/default...5BLN%5D;307220
>
>The article above details that the way to workaround this is to edit the
>machine.config file. This is impossible for me. Luckily there is a
>programmtic way of assigning the proxy settings. The way to do it is
>detailed in this article:
>http://support.microsoft.com/kb/q318140/
>
>The second article explains how to handle requests when there is a proxy
>server between the .NET client and the web service. Unfortunately the
>solution only deals with Web Services. The WebService class has a Proxy
>property to which an object of type of IWebProxy can be passed - and all is
>good.
>
>But in my case, I have an ASP.NET web forms app, not a Web Service. So how
>do I try and route my client requests via the Proxy server programmatically?
>
>What I have tried so far is to use an HttpModule which *should* intercept
>the request and route it through the Proxy server. In the custom
>OnBeginRequest method I have in my HttpModule:
>
>public void OnBeginRequest(object sender, EventArgs e)
>{
> //************************************************** *********************
> WebProxy wp = new WebProxy("http://my.proxy.blah", true);
> //************************************************** *********************
>
> HttpRequest req = ((HttpApplication)sender).Request;
> HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(req.Url.Absolute Uri);
> wr.Proxy = wp;
>
>}
>
>
>However, this doesn't cut it. :-(
>The request obviously does not get routed via the proxy server. Can Anyone
>tried this before and tell me how to workaround this problem.
>
>
>Also, does anyone know if the .NET Framework version 2 (or even the version
>2 beta) addresses the problem of being able to detect proxy settings using
>discovery scripts.
>Thanks.
>CT
>
>
>[/color]

John Saunders
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Rerouting Requests via a Proxy because of .NET "bug"


"Codex Twin" <codex@more.com> wrote in message
news:eE$3U6U2EHA.3132@TK2MSFTNGP14.phx.gbl...[color=blue]
>I am re-sending this in the hope that it might illicit a response. I have a
> corporate client who forces their workstations to get the proxy server
> details using an automatic proxy discovery script.
>
> Unfortunately, the .NET Framework does not support automatic proxy
> discovery
> scripts. See:
> http://support.microsoft.com/default...5BLN%5D;307220[/color]

This article has nothing to do with web forms applications. In a Web Forms
application, the browser sends a request to the server and gets an HTML
response. The browser may be configured to run an automatic proxy discovery
script and to use the discovered proxy to send to the server. The server
should neither know nor care whether one or more proxies were in the path
between the client and the server.
[color=blue]
> The article above details that the way to workaround this is to edit the
> machine.config file. This is impossible for me. Luckily there is a
> programmtic way of assigning the proxy settings. The way to do it is
> detailed in this article:
> http://support.microsoft.com/kb/q318140/
>
> The second article explains how to handle requests when there is a proxy
> server between the .NET client and the web service. Unfortunately the
> solution only deals with Web Services. The WebService class has a Proxy
> property to which an object of type of IWebProxy can be passed - and all
> is
> good.[/color]

....
[color=blue]
> But in my case, I have an ASP.NET web forms app, not a Web Service. So how
> do I try and route my client requests via the Proxy server
> programmatically?[/color]

As I said, "you don't, the browser does".

Obviously something isn't working the way you expect it to, and that makes
you think that you need to do something about proxies. Please tell us what
the symptom is, and we can help you find the disease. The disease is
probably not "server-side proxy setup".

John Saunders


Codex Twin
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Rerouting Requests via a Proxy because of .NET "bug"


Thanks Scott

What I'm really stuck on is the code I need to write to route every request
to my application to this proxy.

Thanks
cT


"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:1531r0tjmog7bngskb224j85nsu419laat@4ax.com...[color=blue]
> Codex:
>
> One way I've worked with proxies is to use the GlobalProxySelection
> class:
>
> GlobalProxySelection.Select = new WebProxy("127.0.0.1", 8888);
>
> Hope this work for you too,
>
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
>
> On Fri, 3 Dec 2004 15:41:37 -0000, "Codex Twin" <codex@more.com>
> wrote:
>[color=green]
> >I am re-sending this in the hope that it might illicit a response. I have[/color][/color]
a[color=blue][color=green]
> >corporate client who forces their workstations to get the proxy server
> >details using an automatic proxy discovery script.
> >
> >Unfortunately, the .NET Framework does not support automatic proxy[/color][/color]
discovery[color=blue][color=green]
> >scripts. See:
> >http://support.microsoft.com/default...5BLN%5D;307220
> >
> >The article above details that the way to workaround this is to edit the
> >machine.config file. This is impossible for me. Luckily there is a
> >programmtic way of assigning the proxy settings. The way to do it is
> >detailed in this article:
> >http://support.microsoft.com/kb/q318140/
> >
> >The second article explains how to handle requests when there is a proxy
> >server between the .NET client and the web service. Unfortunately the
> >solution only deals with Web Services. The WebService class has a Proxy
> >property to which an object of type of IWebProxy can be passed - and all[/color][/color]
is[color=blue][color=green]
> >good.
> >
> >But in my case, I have an ASP.NET web forms app, not a Web Service. So[/color][/color]
how[color=blue][color=green]
> >do I try and route my client requests via the Proxy server[/color][/color]
programmatically?[color=blue][color=green]
> >
> >What I have tried so far is to use an HttpModule which *should* intercept
> >the request and route it through the Proxy server. In the custom
> >OnBeginRequest method I have in my HttpModule:
> >
> >public void OnBeginRequest(object sender, EventArgs e)
> >{
> >[/color][/color]
//************************************************** *********************[color=blue][color=green]
> > WebProxy wp = new WebProxy("http://my.proxy.blah", true);
> >[/color][/color]
//************************************************** *********************[color=blue][color=green]
> >
> > HttpRequest req = ((HttpApplication)sender).Request;
> > HttpWebRequest wr =[/color][/color]
(HttpWebRequest)WebRequest.Create(req.Url.Absolute Uri);[color=blue][color=green]
> > wr.Proxy = wp;
> >
> >}
> >
> >
> >However, this doesn't cut it. :-(
> >The request obviously does not get routed via the proxy server. Can[/color][/color]
Anyone[color=blue][color=green]
> >tried this before and tell me how to workaround this problem.
> >
> >
> >Also, does anyone know if the .NET Framework version 2 (or even the[/color][/color]
version[color=blue][color=green]
> >2 beta) addresses the problem of being able to detect proxy settings[/color][/color]
using[color=blue][color=green]
> >discovery scripts.
> >Thanks.
> >CT
> >
> >
> >[/color]
>[/color]


Codex Twin
Guest
 
Posts: n/a
#5: Nov 21 '05

re: Rerouting Requests via a Proxy because of .NET "bug"



"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:OWxmIVV2EHA.2592@TK2MSFTNGP09.phx.gbl...[color=blue]
> "Codex Twin" <codex@more.com> wrote in message
> news:eE$3U6U2EHA.3132@TK2MSFTNGP14.phx.gbl...[color=green]
> >I am re-sending this in the hope that it might illicit a response. I have[/color][/color]
a[color=blue][color=green]
> > corporate client who forces their workstations to get the proxy server
> > details using an automatic proxy discovery script.
> >
> > Unfortunately, the .NET Framework does not support automatic proxy
> > discovery
> > scripts. See:
> > http://support.microsoft.com/default...5BLN%5D;307220[/color]
>
> This article has nothing to do with web forms applications. In a Web Forms
> application, the browser sends a request to the server and gets an HTML
> response. The browser may be configured to run an automatic proxy[/color]
discovery[color=blue]
> script and to use the discovered proxy to send to the server. The server
> should neither know nor care whether one or more proxies were in the path
> between the client and the server.
>[color=green]
> > The article above details that the way to workaround this is to edit the
> > machine.config file. This is impossible for me. Luckily there is a
> > programmtic way of assigning the proxy settings. The way to do it is
> > detailed in this article:
> > http://support.microsoft.com/kb/q318140/
> >
> > The second article explains how to handle requests when there is a proxy
> > server between the .NET client and the web service. Unfortunately the
> > solution only deals with Web Services. The WebService class has a Proxy
> > property to which an object of type of IWebProxy can be passed - and all
> > is
> > good.[/color]
>
> ...
>[color=green]
> > But in my case, I have an ASP.NET web forms app, not a Web Service. So[/color][/color]
how[color=blue][color=green]
> > do I try and route my client requests via the Proxy server
> > programmatically?[/color]
>
> As I said, "you don't, the browser does".
>
> Obviously something isn't working the way you expect it to, and that makes
> you think that you need to do something about proxies. Please tell us what
> the symptom is, and we can help you find the disease. The disease is
> probably not "server-side proxy setup".
>
> John Saunders
>
>[/color]

John

The scenario is this: The server application I have built uses the ChartFX
(by SoftwareFX) control. This control causes the download of half a dozen or
so "client-side components". These are nothing more than .NET assemblies
which allow all the fancy dynamic chart customisation tools on the browser.
One of the conditions for the client-side dlls to work is that the client
machine has to have the .NET framework installed.

These same machines, being behind the firewall, uses the automatic proxy
discovery script to determine the proxy server settings.
Now, because of the problem detailed in the first article
(http://support.microsoft.com/default...5BLN%5D;307220) and the
fact that the .NET Framework does not support proxy discovery scripts, the
client machine cannot see get the proxy server settings and the charts fail.

When the machine.config file is amended as the article explains, then it
works. I do not have access to their machine.config files, hence the
programmatic way of supplying proxy server settings as detailed in the
second article, which as you have rightly said, only deals with Web
Services.

My problem has been where to impose this programmatic code, and what the
correct code is.





Tom Porterfield
Guest
 
Posts: n/a
#6: Nov 21 '05

re: Rerouting Requests via a Proxy because of .NET "bug"


On Fri, 3 Dec 2004 16:31:02 -0000, Codex Twin wrote:
[color=blue]
> Thanks Scott
>
> What I'm really stuck on is the code I need to write to route every request
> to my application to this proxy.[/color]

If the workstation where the request is initiated is already configured to
use a proxy in their web browser then there is nothing you need to do. The
proxy will be used.
--
Tom Porterfield
Codex Twin
Guest
 
Posts: n/a
#7: Nov 21 '05

re: Rerouting Requests via a Proxy because of .NET "bug"



"Tom Porterfield" <tpporter@mvps.org> wrote in message
news:b3cj2zkgs8ls.dlg@tpportermvps.org...[color=blue]
> On Fri, 3 Dec 2004 16:31:02 -0000, Codex Twin wrote:
>[color=green]
> > Thanks Scott
> >
> > What I'm really stuck on is the code I need to write to route every[/color][/color]
request[color=blue][color=green]
> > to my application to this proxy.[/color]
>
> If the workstation where the request is initiated is already configured to
> use a proxy in their web browser then there is nothing you need to do.[/color]
The[color=blue]
> proxy will be used.
> --
> Tom Porterfield[/color]


Hello Tom
Thanks for the reply.

I *want* the proxy to be used. As I have said in my post to John Saunders,
the application I have needs the .NET Framework on the client machine, and
this does not support the automatic discovery scripts to get the proxy
details. The workaround is either to amend the machine.config file or
programmatic.
My question is, what is the correct code for the programmatic solution.



John Saunders
Guest
 
Posts: n/a
#8: Nov 21 '05

re: Rerouting Requests via a Proxy because of .NET "bug"


"Codex Twin" <codex@more.com> wrote in message
news:OmIOmhV2EHA.3132@TK2MSFTNGP14.phx.gbl...[color=blue]
>[/color]
....[color=blue]
> John
>
> The scenario is this: The server application I have built uses the ChartFX
> (by SoftwareFX) control. This control causes the download of half a dozen
> or
> so "client-side components". These are nothing more than .NET assemblies
> which allow all the fancy dynamic chart customisation tools on the
> browser.
> One of the conditions for the client-side dlls to work is that the client
> machine has to have the .NET framework installed.
>
> These same machines, being behind the firewall, uses the automatic proxy
> discovery script to determine the proxy server settings.
> Now, because of the problem detailed in the first article
> (http://support.microsoft.com/default...5BLN%5D;307220) and
> the
> fact that the .NET Framework does not support proxy discovery scripts, the
> client machine cannot see get the proxy server settings and the charts
> fail.[/color]

Please be more specific. Exactly what do you mean when you say "the charts
fail"?
[color=blue]
> When the machine.config file is amended as the article explains, then it
> works. I do not have access to their machine.config files, hence the
> programmatic way of supplying proxy server settings as detailed in the
> second article, which as you have rightly said, only deals with Web
> Services.
>
> My problem has been where to impose this programmatic code, and what the
> correct code is.[/color]

Whatever the solution is, it will be client-side.

Have you spoken to SoftwareFX about this? You may not be the first to have
this problem.

John Saunders


Codex Twin
Guest
 
Posts: n/a
#9: Nov 21 '05

re: Rerouting Requests via a Proxy because of .NET "bug"



"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:Od3ho%23V2EHA.3368@TK2MSFTNGP10.phx.gbl...[color=blue]
> "Codex Twin" <codex@more.com> wrote in message
> news:OmIOmhV2EHA.3132@TK2MSFTNGP14.phx.gbl...[color=green]
> >[/color]
> ...[color=green]
> > John
> >
> > The scenario is this: The server application I have built uses the[/color][/color]
ChartFX[color=blue][color=green]
> > (by SoftwareFX) control. This control causes the download of half a[/color][/color]
dozen[color=blue][color=green]
> > or
> > so "client-side components". These are nothing more than .NET assemblies
> > which allow all the fancy dynamic chart customisation tools on the
> > browser.
> > One of the conditions for the client-side dlls to work is that the[/color][/color]
client[color=blue][color=green]
> > machine has to have the .NET framework installed.
> >
> > These same machines, being behind the firewall, uses the automatic proxy
> > discovery script to determine the proxy server settings.
> > Now, because of the problem detailed in the first article
> > (http://support.microsoft.com/default...5BLN%5D;307220) and
> > the
> > fact that the .NET Framework does not support proxy discovery scripts,[/color][/color]
the[color=blue][color=green]
> > client machine cannot see get the proxy server settings and the charts
> > fail.[/color]
>
> Please be more specific. Exactly what do you mean when you say "the charts
> fail"?
>[color=green]
> > When the machine.config file is amended as the article explains, then it
> > works. I do not have access to their machine.config files, hence the
> > programmatic way of supplying proxy server settings as detailed in the
> > second article, which as you have rightly said, only deals with Web
> > Services.
> >
> > My problem has been where to impose this programmatic code, and what the
> > correct code is.[/color]
>
> Whatever the solution is, it will be client-side.
>
> Have you spoken to SoftwareFX about this? You may not be the first to have
> this problem.
>
> John Saunders
>[/color]


SoftwareFX have not responded (yet).
I'm halfway there, but have not been able to simulate a Request from a
ChartFX client object. So not there at all, I guess.

Thank you and have a nice weekend...



Dan Rogers
Guest
 
Posts: n/a
#10: Nov 21 '05

re: Rerouting Requests via a Proxy because of .NET "bug"


I have to agree with John. Since the calls to the server are being made
by the ChartFx controls, and you say these request are not seeing your
client configuration for proxy servers, then it is very likely that there
is no code you can add to your own application to make this work. The
exception case, and I would anticipate there to be this case, would be a
property on the chartFx controls that you can set from your client-side
load code to use a proxy.

Is there some reason that your clients need to use a proxy for internal
addresses? very often proxy settings bypass the proxy for local IP
addresses. I suppose that in some environments, the business wants to be
able to monitor every page every user goes to. <brrrrrr>

Dan Rogers
Microsoft Corporation
--------------------
From: "Codex Twin" <codex@more.com>
References: <eE$3U6U2EHA.3132@TK2MSFTNGP14.phx.gbl>
<OWxmIVV2EHA.2592@TK2MSFTNGP09.phx.gbl>
<OmIOmhV2EHA.3132@TK2MSFTNGP14.phx.gbl>
<Od3ho#V2EHA.3368@TK2MSFTNGP10.phx.gbl>
Subject: Re: Rerouting Requests via a Proxy because of .NET "bug"
Date: Fri, 3 Dec 2004 17:54:22 -0000
Lines: 60
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <upB3gEW2EHA.3616@TK2MSFTNGP11.phx.gbl>
Newsgroups:
microsoft.public.dotnet.framework.aspnet,microsoft .public.dotnet.framework.w
ebservices
NNTP-Posting-Host: 193.115.152.15
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP11
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7804
microsoft.public.dotnet.framework.aspnet:280780
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices


"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:Od3ho%23V2EHA.3368@TK2MSFTNGP10.phx.gbl...[color=blue]
> "Codex Twin" <codex@more.com> wrote in message
> news:OmIOmhV2EHA.3132@TK2MSFTNGP14.phx.gbl...[color=green]
> >[/color]
> ...[color=green]
> > John
> >
> > The scenario is this: The server application I have built uses the[/color][/color]
ChartFX[color=blue][color=green]
> > (by SoftwareFX) control. This control causes the download of half a[/color][/color]
dozen[color=blue][color=green]
> > or
> > so "client-side components". These are nothing more than .NET assemblies
> > which allow all the fancy dynamic chart customisation tools on the
> > browser.
> > One of the conditions for the client-side dlls to work is that the[/color][/color]
client[color=blue][color=green]
> > machine has to have the .NET framework installed.
> >
> > These same machines, being behind the firewall, uses the automatic proxy
> > discovery script to determine the proxy server settings.
> > Now, because of the problem detailed in the first article
> > (http://support.microsoft.com/default...5BLN%5D;307220) and
> > the
> > fact that the .NET Framework does not support proxy discovery scripts,[/color][/color]
the[color=blue][color=green]
> > client machine cannot see get the proxy server settings and the charts
> > fail.[/color]
>
> Please be more specific. Exactly what do you mean when you say "the charts
> fail"?
>[color=green]
> > When the machine.config file is amended as the article explains, then it
> > works. I do not have access to their machine.config files, hence the
> > programmatic way of supplying proxy server settings as detailed in the
> > second article, which as you have rightly said, only deals with Web
> > Services.
> >
> > My problem has been where to impose this programmatic code, and what the
> > correct code is.[/color]
>
> Whatever the solution is, it will be client-side.
>
> Have you spoken to SoftwareFX about this? You may not be the first to have
> this problem.
>
> John Saunders
>[/color]


SoftwareFX have not responded (yet).
I'm halfway there, but have not been able to simulate a Request from a
ChartFX client object. So not there at all, I guess.

Thank you and have a nice weekend...




Closed Thread