C# HttpWebRequest 存取 WEB API 不要有Cache的寫法
C# HttpWebRequest 存取 WEB API 不要有Cache的寫法
片段程式碼:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
//–
//定義此req的緩存策略
//https://msdn.microsoft.com/zh-tw/library/system.net.webrequest.cachepolicy(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
request.CachePolicy = noCachePolicy;
//–
request.Method = “GET”;//request.Method = “POST”;