RequestCachePolicy::Level Property
Gets the RequestCacheLevel value specified when this instance was constructed.
Assembly: System (in System.dll)
Property Value
Type: System.Net.Cache::RequestCacheLevelA RequestCacheLevel value that specifies the cache behavior for resources obtained using WebRequest objects.
Applications typically use Default as their cache policy level. Using the Default level, the effective cache policy is determined by the current cache policy and the age of the content in the cache. The WebRequest::CachePolicy property, if not null, determines the cache policy in effect for a request.
The default policy for the application domain can be set using the DefaultCachePolicy or the application or machine configuration file. For more information, see <requestCaching> Element (Network Settings).
The following code example creates a CacheOnly policy and sends a request.
static WebResponse^ GetResponseFromCache( Uri^ uri ) { RequestCachePolicy^ policy = gcnew RequestCachePolicy( RequestCacheLevel::CacheOnly ); 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; }
Available since 2.0