Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.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().DownloadString()返回旧数据_C#_Php_Webclient_Webclient Download - Fatal编程技术网

C# WebClient().DownloadString()返回旧数据

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

我使用此代码从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.DownloadString()
方法返回
code.txt
文件的旧内容。当我打开URL
http://somesite.com/code.php
在浏览器中,它工作得非常好

任何解决方案都将不胜感激

我的问题似乎是重复的,但我真的不明白这里说的是什么:


如果有人能解释并提供一些示例代码,那就太好了

尝试禁用WebClient上的缓存

webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);

我真的不明白这个问题的答案。有没有示例代码?在我提到的问题的答案中有很多有用的提示。您是否尝试过禁用
webclient
中的缓存,甚至切换到
HttpWebRequest