Results 1 to 6 of 6

Thread: [RESOLVED] [1.0/1.1] Connect WebClient through Proxy server

  1. #1

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Resolved [RESOLVED] [1.0/1.1] Connect WebClient through Proxy server

    I've written a simple automatic updater for some old software of ours however it doesn't work through my clients proxy server as it requires authentication.

    I don't want to have to prompt the user to enter their username/password again when they are already logged so is there a way I can grab their credentials?

    Cheers.

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: [1.0/1.1] Connect WebClient through Proxy server


  3. #3

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: [1.0/1.1] Connect WebClient through Proxy server

    I have tried using this with the webclient without success. I'll play a bit more...

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [1.0/1.1] Connect WebClient through Proxy server

    Identity Impersonate set to true, with Windows Auth?

  5. #5

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: [1.0/1.1] Connect WebClient through Proxy server

    At the moment I have:
    Code:
    WebClient myWebClient = new WebClient();
    myWebClient.Credentials = CredentialCache.DefaultCredentials;
    Byte[] myDataBuffer = myWebClient.DownloadData(remoteUri + UpdateFileName);
    But this is unable to authenticate with the proxy server. This needs to work without the user having to supply a username and password.

    I can browse directly to the file (remoteUri + UpdateFileName) using a browser on the users machine.

  6. #6

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: [RESOLVED] [1.0/1.1] Connect WebClient through Proxy server

    Got it working then had a problem if the there wasn't a proxy in place and then the text file that was being retrieved was being cached. Solution in case it helps anyone else out or in case (more likely) someone shows me a better way to do it:
    Code:
    		WebProxy proxy = new WebProxy();
    		proxy = WebProxy.GetDefaultProxy();
    		proxy.Credentials = CredentialCache.DefaultCredentials;
    		GlobalProxySelection.Select = proxy;
    
    		WebClient myWebClient = new WebClient();
    		Byte[] myDataBuffer = myWebClient.DownloadData(remoteUri + UpdateFileName + "?rnd=" + DateTime.Now.Millisecond);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width