Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#:无法绕过缓存(WebClient)_C#_.net_Webclient - Fatal编程技术网

C#:无法绕过缓存(WebClient)

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://

为什么上面的代码实际上没有阻止通过.Net Web客户端缓存站点

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,但它们都不起作用。您如何看到它们正在被缓存?这只是在请求中添加了一个头,它并不控制服务器实际发送的内容。您是如何看到它们被缓存的?这只是在请求中添加了一个头,并不控制服务器实际发送的内容。