FTP File Upload with HTTP Proxy

前端 未结 13 1981
轻奢々
轻奢々 2020-12-05 07:48

Is there a way to upload a file to a FTP server when behind an HTTP proxy ?

It seems that uploading a file is not supported behind an HTTP Proxy using .Net Webclient

13条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 08:18

    Hi I had the same issue - the resolution was to create the proxy object and derive the defaultcredentials - this should be fine provided your application is been run with a network account -

    FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
    
    System.Net.WebProxy proxy = System.Net.WebProxy.GetDefaultProxy();
    proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
    
    // set the ftpWebRequest proxy
    reqFTP.Proxy = proxy;
    

    This resolved the issue for me.

提交回复
热议问题