Posts Tagged ‘FtpWebRequest’

More .Net FtpWebRequest woes

This time it’s an issue with the SIZE command. As explained here,

Some servers require sending “TYPE I” before the SIZE command will work.

Note that setting FtpWebRequest.UseBinary to true (which it is by default) does not correct this. When getting the response, an exception will be thrown telling you the file is unavailable and you’ll get a 550 error with the message, “SIZE not allowed in ASCII mode”.

A discussion and Microsoft’s response to this issue is available here; it pretty much boils down to tough noogies, it’ll be fixed in a future version.

.Net FtpWebRequest and 503 (bad sequence of commands) errors

I’ve been working on some FTP code in C# with the .Net framework’s FTP classes and frustrated that I was occasionally getting 503 (bad sequence of commands) errors. Turns out these errors will pop up if the FtpWebRequest.KeepAlive property is set to true, which it is by default. Unfortunately, this doesn’t really address why this is occurring in the first place. I’m doing a lot of multithreaded stuff, so perhaps that’s the culprit (i.e. 2+ threads using the same connection, layering their calls on top of each other). However, I’ve found some forum posts (such as this one) indicating others are having the same issue doing seemingly serial, non-asynchronous stuff.