Home All Groups Group Topic Archive Search About

The remote server returned an error: (407) Proxy Authentication Re

Author
28 Nov 2007 5:24 PM
Richard@nospam.nospam
My webcam app runs OK on XP but not on Vista.  Here's my code snippet that
has been working up until now:

    System.Net.WebRequest request;
    System.Net.WebResponse response;
    request = System.Net.FileWebRequest.Create(
            "http://store.bearvalley.com/live/camimage_00001.jpg");
    response = request.GetResponse();

When it tries to execute the request.GetResponse() call I get the following
exception:
The remote server returned an error: (407) Proxy Authentication Required.

I can paste the uri into my browser and it works OK.

Any assistance would be greatly appreciated.

Thanks! ;^)

Richard

Author
29 Nov 2007 4:41 AM
Nicholas Paldino [.NET/C# MVP]
Richard,

    You might want to change the code that calls the static Create method to
call off the WebRequest class.  It won't fix your problem, but it makes the
code a little more accurate (considering that you are getting an
HttpWebRequest based on the URL).

    The reason it works for you in your browser is because your browser is
set up correctly to use a proxy.  You have to do the same thing in code,
creating an instance of the WebProxy class, setting the properties on it,
and then setting the Proxy property to that WebProxy instance.


--
          - Nicholas Paldino [.NET/C# MVP]
          - mvp@spam.guard.caspershouse.com

<Richard@nospam.nospam> wrote in message
Show quote
news:F8E09733-85ED-48DB-8EF6-B521DFA49035@microsoft.com...
> My webcam app runs OK on XP but not on Vista.  Here's my code snippet that
> has been working up until now:
>
>    System.Net.WebRequest request;
>    System.Net.WebResponse response;
>    request = System.Net.FileWebRequest.Create(
>            "http://store.bearvalley.com/live/camimage_00001.jpg");
>    response = request.GetResponse();
>
> When it tries to execute the request.GetResponse() call I get the
> following
> exception:
> The remote server returned an error: (407) Proxy Authentication Required.
>
> I can paste the uri into my browser and it works OK.
>
> Any assistance would be greatly appreciated.
>
> Thanks! ;^)
>
> Richard
Author
29 Nov 2007 4:53 PM
Richard@nospam.nospam
Thanks Nicholas!
First I can't create an instance of WebRequest because the compiler gives an
error saying it's an abstract class - I don't know what that means but it
looks like I have to use the static Create method.  So here's what I tried
based on your suggestion:

    System.Net.WebRequest request;
    System.Net.WebResponse response;
    IWebProxy iwp = System.Net.WebRequest.GetSystemWebProxy();
    request = System.Net.WebRequest.Create(
            "http://store.bearvalley.com/live/camimage_00001.jpg");
    request.Proxy = iwp;
    response = request.GetResponse();

When I hover Proxy in the debugger I can see my proxy server address but I'm
still getting the error when it executes the GetResponse call.  Any more
suggestions would be appreciated.

Thanks! ;^)
Richard

Show quote
"Nicholas Paldino [.NET/C# MVP]" wrote:

> Richard,
>
>     You might want to change the code that calls the static Create method to
> call off the WebRequest class.  It won't fix your problem, but it makes the
> code a little more accurate (considering that you are getting an
> HttpWebRequest based on the URL).
>
>     The reason it works for you in your browser is because your browser is
> set up correctly to use a proxy.  You have to do the same thing in code,
> creating an instance of the WebProxy class, setting the properties on it,
> and then setting the Proxy property to that WebProxy instance.
>
>
> --
>           - Nicholas Paldino [.NET/C# MVP]
>           - mvp@spam.guard.caspershouse.com
>
> <Richard@nospam.nospam> wrote in message
> news:F8E09733-85ED-48DB-8EF6-B521DFA49035@microsoft.com...
> > My webcam app runs OK on XP but not on Vista.  Here's my code snippet that
> > has been working up until now:
> >
> >    System.Net.WebRequest request;
> >    System.Net.WebResponse response;
> >    request = System.Net.FileWebRequest.Create(
> >            "http://store.bearvalley.com/live/camimage_00001.jpg");
> >    response = request.GetResponse();
> >
> > When it tries to execute the request.GetResponse() call I get the
> > following
> > exception:
> > The remote server returned an error: (407) Proxy Authentication Required.
> >
> > I can paste the uri into my browser and it works OK.
> >
> > Any assistance would be greatly appreciated.
> >
> > Thanks! ;^)
> >
> > Richard
>

AddThis Social Bookmark Button