RequestCachePolicy.ToString Method ()


Returns a string representation of this instance.

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

public override string ToString()

Return Value

Type: System.String

A String containing the Level for this instance.

The following code example creates a NoCacheNoStore policy and sends a request.

public static WebResponse GetResponseFromServer(Uri uri)
     RequestCachePolicy policy = 
        new  RequestCachePolicy( RequestCacheLevel.NoCacheNoStore);
    WebRequest request = WebRequest.Create(uri);
    request.CachePolicy = policy;
    WebResponse response = request.GetResponse();
    Console.WriteLine("Policy is {0}.", policy.ToString());
    Console.WriteLine("Is the response from the cache? {0}", response.IsFromCache);  
    return response;


.NET Framework
Available since 2.0
Return to top