c# HttpClient禁止缓存 |
您所在的位置:网站首页 › nocac › c# HttpClient禁止缓存 |
using (var client = new HttpClient()) { //方法1: CacheControlHeaderValue cacheControl = new CacheControlHeaderValue(); cacheControl.NoCache = true; cacheControl.NoStore = true; client.DefaultRequestHeaders.CacheControl = cacheControl; //方法2: //client.DefaultRequestHeaders.Add("Cache-Control", "no-cache"); try { client.GetStringAsync(url); return true; } catch { return false; } } |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |