Condividi tramite


HttpRequestCachePolicy.Level Proprietà

Definizione

Ottiene il HttpRequestCacheLevel valore specificato al momento della creazione dell'istanza.

public:
 property System::Net::Cache::HttpRequestCacheLevel Level { System::Net::Cache::HttpRequestCacheLevel get(); };
public System.Net.Cache.HttpRequestCacheLevel Level { get; }
member this.Level : System.Net.Cache.HttpRequestCacheLevel
Public ReadOnly Property Level As HttpRequestCacheLevel

Valore della proprietà

Valore HttpRequestCacheLevel che specifica il comportamento della cache per le risorse ottenute tramite HttpWebRequest oggetti .

Esempio

Nell'esempio di codice seguente viene illustrato il valore di questa proprietà.

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;
}

Commenti

Le applicazioni in genere usano Default come livello di criteri della cache. La CachePolicy proprietà, se non null, determina i criteri della cache in vigore per una richiesta. I criteri predefiniti per il dominio applicazione possono essere impostati usando la DefaultCachePolicy proprietà o le impostazioni nei file di configurazione del computer o dell'applicazione. Per altre informazioni, vedere elemento requestCaching (impostazioni di rete).For more information, see< requestCaching> Element (Network Settings).

Si applica a