RequestCachePolicy.ToString 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回這個執行個體的字串表示。
public:
override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
傳回
範例
下列程式代碼範例會建立原則 NoCacheNoStore 並傳送要求。
static WebResponse^ GetResponseFromServer( Uri^ uri )
{
RequestCachePolicy^ policy = gcnew RequestCachePolicy( RequestCacheLevel::NoCacheNoStore );
WebRequest^ request = WebRequest::Create( uri );
request->CachePolicy = policy;
WebResponse^ response = request->GetResponse();
Console::WriteLine( L"Policy is {0}.", policy );
Console::WriteLine( L"Is the response from the cache? {0}", response->IsFromCache );
return response;
}
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;
}