我正在使用此代码从 URL 获取返回字符串
webClient.Encoding = Encoding.UTF8;
response = webClient.DownloadString("http://somesite.com/code.php");
Console.Write(response);
the code.php
看起来像这样
<?php
$data = file_get_contents('code.txt');
echo $data;
?>
问题是当我更改内容时code.txt
文件,该webClient.DownloadString()
方法返回旧的内容code.txt
文件。当我打开网址时http://somesite.com/code.php
在浏览器中它工作得很好。
任何解决方案将不胜感激!
我的问题似乎是重复的,但我不太明白这里说的是什么:C# WebClient 禁用缓存 https://stackoverflow.com/questions/3812089/c-sharp-webclient-disable-cache
如果有人可以解释并提供一些示例代码,那就太好了!
尝试禁用 WebClient 上的缓存
webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
有关 WebClient 缓存的 MSDN 文档 https://msdn.microsoft.com/en-us/library/system.net.webclient.cachepolicy%28v=vs.110%29.aspx
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)