locked
Local Computer->Proxy->FTP = Error 407 Proxy authentification settings RRS feed

  • Question

  • Hi all,

    I try to download a file on a FTP site through a Proxy. I would like to get Internet Explorer Proxy settings.

    {
    FtpWebRequest ftpRequest = null;
    FtpWebResponse ftpResponse = null;
    
    try {
          ftpRequest = (FtpWebRequest)FtpWebRequest.Create(@"ftp://ftp.dell.com/catalog/DellSDPCatalogPC.cab");
    
          ftpRequest.Proxy = GetWebProxy();
    
          ftpRequest.UseBinary = true;
          ftpRequest.UsePassive = true;
          ftpRequest.KeepAlive = true;
          ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile;
          ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
          // Error 407 : Proxy Authentification Required.
        }
    }
    
    private System.Net.IWebProxy GetWebProxy()
        {
            System.Net.IWebProxy proxy = System.Net.WebRequest.GetSystemWebProxy();
            proxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
            return proxy;
        }

    The code for GetWebProxy work perfectly if I use it for a HTTP download, the app pass through Proxy and download the file (in a HTTP site). But If I use it to go to a FTP site, It failed with 407 Error. It's just like FTP can't use pre-recorded credentials in Internet Explorer. What happen ? How to get Internet Explorer Proxy Settings for a ftpRequest.Proxy object ?

    Thanks for your suggestions.


    David COURTEL
    IT Technician
    Wsus Third-Party Softwares Publishing : http://wsuspackagepublisher.codeplex.com


    • Edited by DCourtel Friday, October 25, 2013 7:19 PM
    Friday, October 25, 2013 7:14 PM

Answers

  • Hi, and thank you for you answer.

    I have finally give up the idea to get Internet Explorer proxy settings. If I need to get from the user, his login and password, I should ask him the Proxy Server name as well.

    In addition, FtpWebRequest can not be used to upload a file or asking the File modification LastDateTime. Don't know why, but it' s like that.

    My application will propose these two options, 'don't use proxy' and 'Use these settings : '.


    David COURTEL
    IT Technician
    Wsus Third-Party Softwares Publishing : http://wsuspackagepublisher.codeplex.com

    • Marked as answer by DCourtel Tuesday, October 29, 2013 2:41 PM
    • Edited by DCourtel Tuesday, October 29, 2013 2:41 PM
    Tuesday, October 29, 2013 2:41 PM

All replies

  • Hi DCourtel,

    If you want to download files via FtpWebRequest with the default ie proxy setting, you could just set the ftpRequest.Proxy =null, if this still doesn't work, probably you need to specify the proxy.Credentials with a specified username and password.

    Please check the document from MSDN:

    FtpWebRequest.Proxy Property

    The Proxy property identifies the IWebProxy instance that communicates with the FTP server. The proxy is set by the system by using configuration files and the Internet Explorer Local Area Network settings. To specify that no proxy should be used, set Proxy to the proxy instance returned by the GlobalProxySelection.GetEmptyWebProxy method. For more information about automatic proxy detection, see Automatic Proxy Detection.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 29, 2013 2:09 AM
  • Hi, and thank you for you answer.

    I have finally give up the idea to get Internet Explorer proxy settings. If I need to get from the user, his login and password, I should ask him the Proxy Server name as well.

    In addition, FtpWebRequest can not be used to upload a file or asking the File modification LastDateTime. Don't know why, but it' s like that.

    My application will propose these two options, 'don't use proxy' and 'Use these settings : '.


    David COURTEL
    IT Technician
    Wsus Third-Party Softwares Publishing : http://wsuspackagepublisher.codeplex.com

    • Marked as answer by DCourtel Tuesday, October 29, 2013 2:41 PM
    • Edited by DCourtel Tuesday, October 29, 2013 2:41 PM
    Tuesday, October 29, 2013 2:41 PM