2009/06/30

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:
&rc:emissionTime=633819525738564717
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.

2009/06/11

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"

WebRequest
using System.Net;  //don't forget this
public string DownloadFile(string url, string username, string pw)
{
  string strResult = "";
  try
  {
    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();
      sr.Close();
    }

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

2009/06/03

ASP.Net: State Management

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