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;
}
转载于:https://www.cnblogs.com/08shiyan/archive/2012/04/21/2462473.html