Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review



Hi, Oh ok.
Thank you for the information!


Re: folder paths

If you did RemotePath.Combine("/olympusWeb/webdav", "/TestCoda"), it will indeed return "/TestCoda". That's the expected behavior. It returns the effective path that /TestCoda will result in, as if you were in /olympusWeb/webdav working directory. As your path is absolute (starts with slash), the working directory is irrelevant.

folder paths


I had set the rootfolder, so I assumed this root folder shouldn't be repeated any longer. But it was indeed the cause of the problem. The wrong path caused the 302 redirect to some login page because the directory was not allowed/accessible.
I had already tried including the full path as second arg in PutFileToDirectory using RemotePath.Combine(), however, during debugging I now see the paths don't get attached (in fact, I only get the second string returned, being /TestCoda)
When I attach them manually (rootFolder + targetfolder) I see it works now, I see the file arrived using WinSCP GUI!

Thank you so much for the support!


WebDAV GUI log


Yes, I meant WinSCP GUI. See attachment for the log file you requested. Hopefully this clarifies the proces.
I don't think it's normal a 'client code' is requested. Since I don't have to enter one on the GUI, I would expect it to work also without a 'client code' using the WinSCP NuGet package?


Re: winscp client

I assume that by "WinSCP client", you mean the WinSCP GUI. If that's connect, please post complete GUI session log file showing a successful upload.

winscp client


Yes, when using the same credentials for opening a session in WinSCP client, I can copy a file there manually.
In code, I can list files, the problem only arise when calling PutFileToDirectory.


Re: Session log

It seems the server is redirecting you to some login page that asks for "client code". Is that expected? I do not see how this can work with WebDAV clients. Can you upload the file using any WebDAV client at all?

Session log


I found the session log. Apparently it was saved in a different location then the debug log, even tough I set no folder for both Paths. Since I didn't see it, I thought it was not generated :)
See attachment for the session log.

Thanks for looking into this!

Re: Upload file using WebDAV protocol fails

Please try to get the session log. It shouldn't be difficult to make it working. If you have problems, please post your code and debug log of the session, where session logging isn't working.

Upload file using WebDAV protocol fails


I'm developing a .NET core app (no GUI, just a service that runs jobs once in a while). It checks if a file exists on a WebDAV folder, if not, it copies the file to the target.
I am able to list the files in the WebDAV folder (When Debugging, I can see the list of fetched files).
I use WinSCP NuGet version 5.21.5 (currently the latest)
However, when I try to upload the file using session.PutFileToDirectory, I get the following error:
Error transferring file 'C:\dev\ConfiDesk\confidesk-api\Confidesk.Api\LocalTmpStorage\CDA128-20221118-OR1TMAA19K.TXT'.
WebDAV resource moved to '**'.
302 Moved Temporarily

=> '**' was not the host I configured for the session. I also cannot see the file on the target folder, it clearly failed. But I cannot see what went wrong. Can you please assist?
In order to give you more feedback, I attached a debugLog (I tried also creating a session log by setting the SessionLogPath, but the logfile does not get created.
In the debuglog file, you can see, before the mention of 302 Moved temporarily, there is a mention of 502 Bad Gateway. Maybe this points to the actual problem?
Please let me know if you need any more information.

Thank you!