Weclient class and proxies

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?SmFsaWw=?=

    Weclient class and proxies

    My code below works fine when I am no using web proxy:


    //login and pwd is for the remote server.
    NetworkCredenti al netCredential = new NetworkCredenti al(login,pwd);
    WebClient client = new WebClient();
    client.Credenti als = netCredential;
    Console.WriteLi ne(client.Downl oadString(Reque stUrl));

    However, when I run behind a proxy I get an exception that I need to
    authenticate to the proxy.

    How would I do this in my program? I read in the doc the WebClient by
    default uses IE proxy settings? Is that true?

    Thanks,

    -Jalil
  • sloan

    #2
    Re: Weclient class and proxies





    ?


    "Jalil" <Jalil@discussi ons.microsoft.c omwrote in message
    news:D6792665-F64A-47B2-8ADE-5F3B4383348A@mi crosoft.com...
    My code below works fine when I am no using web proxy:
    >
    >
    //login and pwd is for the remote server.
    NetworkCredenti al netCredential = new NetworkCredenti al(login,pwd);
    WebClient client = new WebClient();
    client.Credenti als = netCredential;
    Console.WriteLi ne(client.Downl oadString(Reque stUrl));
    >
    However, when I run behind a proxy I get an exception that I need to
    authenticate to the proxy.
    >
    How would I do this in my program? I read in the doc the WebClient by
    default uses IE proxy settings? Is that true?
    >
    Thanks,
    >
    -Jalil

    Comment

    • =?Utf-8?B?SmFsaWw=?=

      #3
      Re: Weclient class and proxies

      Sloan,

      Yes, I had seen this info before. It says:

      The Proxy property identifies the IWebProxy instance that communicates with
      remote servers on behalf of this WebClient object. The proxy is set by the
      system using configuration files and the Internet Explorer Local Area Network
      settings. To specify that no proxy should be used, set the Proxy property to
      the proxy instance returned by the GetEmptyWebProx y method.

      But how would I set this property to the what IE is configured to use?

      Thanks,

      -Jalil


      "sloan" wrote:
      >
      >

      >
      ?
      >
      >
      "Jalil" <Jalil@discussi ons.microsoft.c omwrote in message
      news:D6792665-F64A-47B2-8ADE-5F3B4383348A@mi crosoft.com...
      My code below works fine when I am no using web proxy:


      //login and pwd is for the remote server.
      NetworkCredenti al netCredential = new NetworkCredenti al(login,pwd);
      WebClient client = new WebClient();
      client.Credenti als = netCredential;
      Console.WriteLi ne(client.Downl oadString(Reque stUrl));

      However, when I run behind a proxy I get an exception that I need to
      authenticate to the proxy.

      How would I do this in my program? I read in the doc the WebClient by
      default uses IE proxy settings? Is that true?

      Thanks,

      -Jalil
      >
      >
      >

      Comment

      • sloan

        #4
        Re: Weclient class and proxies

        Did you look at the sample code?

        // Obtain the 'Proxy' of the Default browser.
        IWebProxy proxy = myWebRequest.Pr oxy;





        "Jalil" <Jalil@discussi ons.microsoft.c omwrote in message
        news:4F61FB4B-8895-4E18-A499-5A229A0C8E4A@mi crosoft.com...
        Sloan,
        >
        Yes, I had seen this info before. It says:
        >
        The Proxy property identifies the IWebProxy instance that communicates
        with
        remote servers on behalf of this WebClient object. The proxy is set by the
        system using configuration files and the Internet Explorer Local Area
        Network
        settings. To specify that no proxy should be used, set the Proxy property
        to
        the proxy instance returned by the GetEmptyWebProx y method.
        >
        But how would I set this property to the what IE is configured to use?
        >
        Thanks,
        >
        -Jalil
        >
        >
        "sloan" wrote:
        >
        >>
        >>
        >http://msdn.microsoft.com/en-us/libr...xy(VS.80).aspx
        >>
        >?
        >>
        >>
        >"Jalil" <Jalil@discussi ons.microsoft.c omwrote in message
        >news:D679266 5-F64A-47B2-8ADE-5F3B4383348A@mi crosoft.com...
        My code below works fine when I am no using web proxy:
        >
        >
        //login and pwd is for the remote server.
        NetworkCredenti al netCredential = new NetworkCredenti al(login,pwd);
        WebClient client = new WebClient();
        client.Credenti als = netCredential;
        Console.WriteLi ne(client.Downl oadString(Reque stUrl));
        >
        However, when I run behind a proxy I get an exception that I need to
        authenticate to the proxy.
        >
        How would I do this in my program? I read in the doc the WebClient by
        default uses IE proxy settings? Is that true?
        >
        Thanks,
        >
        -Jalil
        >>
        >>
        >>

        Comment

        Working...