我使用这段代码从URL获取返回字符串
webClient.Encoding = Encoding.UTF8;
response = webClient.DownloadString("http://somesite.com/code.php");
Console.Write(response);code.php看起来像这样
<?php
$data = file_get_contents('code.txt');
echo $data;
?>问题是,当我更改code.txt文件的内容时,webClient.DownloadString()方法返回code.txt文件的旧内容。当我在浏览器中打开URL http://somesite.com/code.php时,它工作得非常好。
任何解决方案都将不胜感激!
我的问题似乎是重复的,但我不太明白这里说的是什么:C# WebClient禁用缓存
如果有人能解释并提供一些示例代码,那就太好了!
发布于 2015-07-14 09:58:38
尝试禁用WebClient上的缓存
webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);https://stackoverflow.com/questions/31403130
复制相似问题