C#:无法绕过缓存(WebClient)
为什么上面的代码实际上没有阻止通过.Net Web客户端缓存站点C#:无法绕过缓存(WebClient),c#,.net,webclient,C#,.net,Webclient,为什么上面的代码实际上没有阻止通过.Net Web客户端缓存站点 WebClient Client = new WebClient(); Client.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.BypassCache); 使用无缓存无存储 编辑:如果不起作用,请尝试webrequest/webresponse: string xmlUrl = "http://
WebClient Client = new WebClient();
Client.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.BypassCache);
使用无缓存无存储
编辑:如果不起作用,请尝试webrequest/webresponse:
string xmlUrl = "http://myserver.com/xmlfile.xml";
WebClient client = new WebClient();
// prevent file caching by windows
client.CachePolicy = new System.Net.Cache.RequestCachePolicy(
System.Net.Cache.RequestCacheLevel.NoCacheNoStore
);
// read content of file
Stream rssStream = client.OpenRead(xmlUrl);
使用无缓存无存储
编辑:如果不起作用,请尝试webrequest/webresponse:
string xmlUrl = "http://myserver.com/xmlfile.xml";
WebClient client = new WebClient();
// prevent file caching by windows
client.CachePolicy = new System.Net.Cache.RequestCachePolicy(
System.Net.Cache.RequestCacheLevel.NoCacheNoStore
);
// read content of file
Stream rssStream = client.OpenRead(xmlUrl);
我尝试了NoCacheNoStore和BypassCache,但它们都不起作用。我尝试了NoCacheNoStore和BypassCache,但它们都不起作用。您如何看到它们正在被缓存?这只是在请求中添加了一个头,它并不控制服务器实际发送的内容。您是如何看到它们被缓存的?这只是在请求中添加了一个头,并不控制服务器实际发送的内容。