Tuesday, October 4, 2011

Caching works with Web Services.....


DO YOU KNOW CACHING WORKS WITH A WEBSERVICE.....

using System.Web.Caching;

...

HttpContext.Current.Cache[key] == "some value";
string value = HttpContext.Current.Cache[key].ToString();

(500) Errors while uploading the files to FTP using c#.

(500) Syntax error, command unrecognized.


FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftppath);request.UsePassive=
false;


UsePassive: Specifies whether to use either active or passive mode. Earlier, active FTP worked fine with all clients, but now, as most of the random ports are blocked by a firewall, the active mode may fail. 



The passive FTP is helpful in this case. But still, it causes issues at the server. 


The higher ports requested by client on server may also be blocked by a firewall. But, because FTP servers will need to make their servers accessible to the greatest number of clients, they will almost certainly need to support passive FTP. 


Passive mode is considered safe because it ensures all data flow initiation comes from inside (client) the network rather than from the outside (server).

(503) Errors while uploading the files to FTP using c#.

(503) Bad sequence of commands.

I ran into this problem too, also when downloading a number of files. During the operation, the FTP QUIT command was never being issued, so a subsequent attempt to log onto and fetch a file reused the same connection, on which the user was still logged in. The underlying error was not "503 Bad sequence of commands" but "503 You are already logged in!".


So you could modify your code to reuse the existing connection to download subsequent files, or add 


FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftppath);


request.KeepAlive=False 


to the web request, and it will force the FTP QUIT command to be issued when you close it.