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