Share via


HttpRequestCachePolicy.Level Properti

Definisi

Mendapatkan nilai yang ditentukan saat instans HttpRequestCacheLevel ini dibuat.

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

Nilai Properti

HttpRequestCacheLevel Nilai yang menentukan perilaku cache untuk sumber daya yang diperoleh menggunakan HttpWebRequest objek.

Contoh

Contoh kode berikut menunjukkan menampilkan nilai properti ini.

static WebResponse^ GetResponseUsingCacheDefault( Uri^ uri )
{
   // Set  the default cache policy level for the "http:" scheme.
   RequestCachePolicy^ policy = gcnew RequestCachePolicy;

   // Create the request.
   WebRequest^ request = WebRequest::Create( uri );
   request->CachePolicy = policy;
   WebResponse^ response = request->GetResponse();
   Console::WriteLine( L"Policy level is {0}.", policy->Level );
   Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache );
   return response;
}
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;
}

Keterangan

Aplikasi biasanya digunakan Default sebagai tingkat kebijakan cache mereka. Properti CachePolicy , jika tidak null, menentukan kebijakan cache yang berlaku untuk permintaan. Kebijakan default untuk domain aplikasi dapat diatur menggunakan DefaultCachePolicy properti atau dengan pengaturan dalam file konfigurasi komputer atau aplikasi. Untuk informasi selengkapnya, baca <requestCaching> Elemen (Pengaturan Jaringan).

Berlaku untuk