WebDav Authentication Issue in .net
hen using the Windows interface of WinSCP 5.9.3, I can connect to server and send files, using WebDAV over port 443 without issue. I have generated the .net code using the Manage --> Generate Session/URL code, and .NET assembly tab and have copied that code to my .net project as follows (I have not included the real server, username or password below):
/ Set up session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Webdav,
HostName = "my.targetserver.com",
PortNumber = 443,
UserName = "myusername",
Password = "mypassword",
WebdavSecure = true,
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
// Your code
}
However, when the code reaches the session.Open line of code, I get:
SessionRemoteException was caught. Authentication failed. Could not authenticate to server. rejected Basic challenge. Connection failed.
The hostname in my code is correct.
The username in my code is correct.
The password in my code is correct.
The code was copied from the Manage, Generate tab as noted above.
Any ideas that might help me get this resolved?
Thanks,
Tim
/ Set up session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Webdav,
HostName = "my.targetserver.com",
PortNumber = 443,
UserName = "myusername",
Password = "mypassword",
WebdavSecure = true,
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
// Your code
}
However, when the code reaches the session.Open line of code, I get:
SessionRemoteException was caught. Authentication failed. Could not authenticate to server. rejected Basic challenge. Connection failed.
The hostname in my code is correct.
The username in my code is correct.
The password in my code is correct.
The code was copied from the Manage, Generate tab as noted above.
Any ideas that might help me get this resolved?
Thanks,
Tim