HttpRequestCachePolicy.Level Свойство
В этой статье
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает значение HttpRequestCacheLevel, заданное при создании экземпляра.
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
Значение HttpRequestCacheLevel, указывающее поведение кэша по отношению к ресурсам, полученным с помощью объектов HttpWebRequest.
В следующем примере кода показано отображение значения этого свойства.
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;
}
Приложения обычно используют Default в качестве уровня политики кэша. Свойство CachePolicy , если нет null
, определяет политику кэша, действовав для запроса. Политику по умолчанию для домена приложения можно задать с помощью DefaultCachePolicy свойства или параметров в файлах конфигурации компьютера или приложения. Дополнительные сведения см. в разделе <элемент requestCaching> (параметры сети).
Продукт | Версии |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |