日期:2014-05-17 浏览次数:20948 次
public static WebResponse GetResponseNoCache(Uri uri) { // Set a default policy level for the "http:" and "https" schemes. HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Default); HttpWebRequest.DefaultCachePolicy = policy; // Create the request. WebRequest request = WebRequest.Create(uri); // Define a cache policy for this request only. HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); request.CachePolicy = noCachePolicy; WebResponse response = request.GetResponse(); Console.WriteLine("IsFromCache? {0}", response.IsFromCache); return response; }