views:

331

answers:

1

Hi

I keep getting this error when I do some ftp requests through my C# code using ftpWebRequest

System.Net.WebException was caught
  Message="The remote server returned an error: (501) Syntax error in parameters or arguments."
  Source="System"
  StackTrace:
       at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
       at System.Net.FtpWebRequest.RequestCallback(Object obj)
       at System.Net.CommandStream.InvokeRequestCallback(Object obj)
       at System.Net.CommandStream.Abort(Exception e)
       at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
       at System.Net.FtpWebRequest.GetResponse()
       at CMS.Controllers.CMSController.GrabWebPage(String webPath) in n:

The thing is though it only happens sometimes. If I do 20 requests I may only get this once and I don't understand why since what I am doing is I dynamically made the requests and I am just switching back and forth between them.

This is what I do

  1. Figure out the path to the file on the server
  2. Dynamically split the paths out onto a webpage..
  3. click on one of these paths and it sends the path to the server
  4. does an ftpWebRequest to find the file
  5. downloads the file and spit the contents onto the page through ajax.

So I have made 2 dynamic links like this on my webpage and I just switch back and forth between them and after X amount of times it I get this error. So I don't see how the syntax is wrong when it worked X amount of times and since I am sending the path through ajax it is not like the page is getting refreshed and it the paths being recreated it is the same path.

So what should I be looking for to try to figure out why I am getting this problem. What kind of syntax might make this error come up?

A: 

If you are not accessing the same file every time, it could be that there is an issue with the file name/path. If you can guarantee yourself that your requests+payload are all identical, then there is something wrong with the server, otherwise, one of your payloads (filename, etc) is not being accepted by the server.

If you have access to the debugger info of the request object, it would help, too.

MandoMando