RequestCachePolicy Constructor ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Initializes a new instance of the RequestCachePolicy class.

Namespace:   System.Net.Cache
Assembly:  System (in System.dll)

public RequestCachePolicy()

This constructor initializes the Level property to Default.

The following example demonstrates calling this constructor.

public static WebResponse GetResponseUsingCacheDefault(Uri uri)
    // Set  the default cache policy level for the "http:" scheme.
    RequestCachePolicy policy = new RequestCachePolicy();
    // Create the request.
    WebRequest request = WebRequest.Create(uri);
    request.CachePolicy = policy;
    WebResponse response = request.GetResponse();
    Console.WriteLine("Policy level is {0}.", policy.Level.ToString());
    Console.WriteLine("Is the response from the cache? {0}", response.IsFromCache);  

    return response;

.NET Framework
Available since 2.0
Return to top