2017-01-25 4 views
0

Ich versuche, die Datei zu speichern werfen SFTP.Its funktioniert, wenn ich auf unserem Unternehmen Server bereitgestellt, aber wenn ich auf dem Produktionsserver bereitgestellt es gibt mir Fehler. Hier ist der CodeSFTP werfen Nullargument Ausnahme nach der Bereitstellung auf Produktionsserver

string host = "https://xyz.in"; 
    int port = 22; 
    string username = "abc"; 
    string password = "xyz" 
    string SftpfolderName = "Images" 

using (var client = new SftpClient(host, port, username, password)) 
      { 
client.Connect(); 
} 

mit (var client = new SftpClient (Host, Port, Benutzername, Passwort) zu werfen Ausnahme unten sind die Ausnahme Details

Web Application $ |. Method $ | 3017 $ | $ | { "Classname" : "System.ArgumentException", "Message": "Host", "Data": null, "InnerException": null, "HelpURL": null, "StackTraceString": "in Renci.SshNet.Connecti onInfo..ctor (String-Host, Int32-Port, String-Benutzername, ProxyTypes proxyType, String proxyHost, Int32-proxyPort, String proxyUsername, String proxyPassword, AuthenticationMethod [] authenticationMethods) \ r \ n unter Renci.SshNet.PasswordConnectionInfo..ctor (String-Host , Int32-Port, String-Benutzername, Byte [] -Passwort, ProxyTypes proxyType, String proxyHost, Int32 proxyPort, String proxyUsername, String proxyPassword) \ r \ n bei Renci.SshNet.SftpClient..ctor (String-Host, Int32-Port, String-Benutzername, String-Passwort) \ r \ n Renci.ShNet.AuthenticationMethod []) "," HResult ": - 2147024809," Quelle ":" Renci.SshNet "," WatsonBuckets ": null," ParamName ": null} 1/25/2017 11:54:24 Uhr

Antwort

0

Ich fand die Ursache für diesen Fehler..in meinem Fall war das Problem, ich habe die "https: //" im Hostnamen hinzugefügt, wenn ich "https: //" aus entfernte Hostname funktioniert. jetzt der Code wie folgt aussehen

string host = "xyz.in"; 
int port = 22; 
string username = "abc"; 
string password = "xyz" 
string SftpfolderName = "Images"; 
using (var client = new SftpClient(host, port, username, password)) 
     { 
client.Connect(); 

}