C# WebClient().DownloadString()返回旧数据
我使用此代码从URL获取返回字符串C# WebClient().DownloadString()返回旧数据,c#,php,webclient,webclient-download,C#,Php,Webclient,Webclient Download,我使用此代码从URL获取返回字符串 webClient.Encoding = Encoding.UTF8; response = webClient.DownloadString("http://somesite.com/code.php"); Console.Write(response); php的code.php如下所示 <?php $data = file_get_contents('code.txt'); echo $data; ?> 问题是当我更改code.txt
webClient.Encoding = Encoding.UTF8;
response = webClient.DownloadString("http://somesite.com/code.php");
Console.Write(response);
php的code.php
如下所示
<?php
$data = file_get_contents('code.txt');
echo $data;
?>
问题是当我更改code.txt
文件的内容时,webClient.DownloadString()
方法返回code.txt
文件的旧内容。当我打开URLhttp://somesite.com/code.php
在浏览器中,它工作得非常好
任何解决方案都将不胜感激
我的问题似乎是重复的,但我真的不明白这里说的是什么:
如果有人能解释并提供一些示例代码,那就太好了 尝试禁用WebClient上的缓存
webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
我真的不明白这个问题的答案。有没有示例代码?在我提到的问题的答案中有很多有用的提示。您是否尝试过禁用
webclient
中的缓存,甚至切换到HttpWebRequest
?