publicstaticWebResponseGetResponseNoCache(Uri uri)
{
// Set a default policy level for the "http:" and "https" schemes.
HttpRequestCachePolicy policy =newHttpRequestCachePolicy(HttpRequestCacheLevel.Default);
HttpWebRequest.DefaultCachePolicy= policy;
// Create the request.
WebRequest request =WebRequest.Create(uri);
// Define a cache policy for this request only.
HttpRequestCachePolicy noCachePolicy =newHttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
request.CachePolicy= noCachePolicy;
WebResponse response = request.GetResponse();
Console.WriteLine("IsFromCache? {0}", response.IsFromCache);
return response;
}