Tips: Prevent SSRS report caching

There are many ways to turn off the report cache, but many of them need you to have enough privilege to change the report or server settings. There is one approach that everyone can do without any privilege: comtrol the parameters in the url.

Append this commend to the end of the url:
The number should be random, and you can do like this:
"http://.....&rc:emissionTime=" + DateTime.Now.Ticks;

The it's the same trick like this one.


Tips: Use String.IsNullOrEmpty() instead of != "" to check empty string

According to FxCop's recommendation, use String.IsNullOrEmpty() is a good approach to check the String is empty or not.

Case 1:
//No good
strUsername != ""
Case 2:
strUsername.Length != 0
Case 3:
//The Best
Reason: Equals requires more MSIL instructions than the other two. Length will throw an exception if the string is null. IsNullOrEmpty has the same performance with Length but also takes care of the null problem.

Go here for more detail information and example.


Download a single file from the remote FTP site (Updated)

Three approaches to download a file from FTP server: WebRequest, FtpWebRequest, and WebClient. Here are the examples:
url = "ftp://xxx.xxx.xxx.xxx/test.txt"

using System.Net;  //don't forget this
public string DownloadFile(string url, string username, string pw)
  string strResult = "";
    WebRequest oRequest = HttpWebRequest.Create(new Uri(url));
    oRequest.Credentials = new NetworkCredential(username, pw);
    WebResponse oResponse = oRequest.GetResponse();

    using (StreamReader sr = new StreamReader(oResponse.GetResponseStream()))
      strResult = sr.ReadToEnd();

    oRequest = null;
    oResponse = null;
  catch (WebException wex)
    //your error handling here
  return strResult;


ASP.Net: State Management

I strongly recommend this document (from MS) if you would like to truly understand this topic.