HttpWebResponse和HttpWebRequest不立即从服务器获取更新文件??? [英] HttpWebResponse and HttpWebRequest dont get updated file from the server immediately???

查看:70
本文介绍了HttpWebResponse和HttpWebRequest不立即从服务器获取更新文件???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用HttpWebResponse和HttpWebRequest从服务器获取更新的XML


源代码如下:


 HttpWebResponse响应; 
HttpWebRequest请求;

Request =(HttpWebRequest)HttpWebRequest.Create(url);

Request.Credentials = CredentialCache.DefaultCredentials;
//Request.Credentials = new NetworkCredential(this.LoginUserName,this.LoginUserPass);

Request.Timeout = 10000;

响应=(HttpWebResponse)Request.GetResponse();


但似乎HttpWebResponse和HttpWebRequest在服务器上没有更新文件。


例如:我将一个文件:abc.xml放到服务器上。


使用WebResponse和WebResponse加载该文件abc.xml很好。


但之后我更新了abc.xml文件。但是再次运行它,将检索旧的包含abc.xml。


大约20分钟后,再次运行它,将检索更新的abc.xml?


但是,在浏览器(谷歌浏览器)上调用abc.xml链接时,会删除文件abc.xml,其中包含最近的更改。 


你能否就解决这个问题给我一个建议?


 


提前致谢。

解决方案

您可以尝试通过将IfModifiedSince属性设置为过去的某个时间来强制它...


Cristian。


Hi,

I am using HttpWebResponse and HttpWebRequest to get an updated XML from the server

The source code is as following:

HttpWebResponse Response;
        HttpWebRequest Request;

        Request = (HttpWebRequest)HttpWebRequest.Create(url);        
        
        Request.Credentials = CredentialCache.DefaultCredentials;
        //Request.Credentials = new NetworkCredential(this.LoginUserName, this.LoginUserPass);

        Request.Timeout = 10000;

        Response = (HttpWebResponse)Request.GetResponse();

But it seems the HttpWebResponse and HttpWebRequest dont get a file updated on the server.

For example: I put a file: abc.xml to the server.

Loading that file abc.xml using WebResponse and WebResponse is fine.

But after that I updated the abc.xml file. But running it again, the old contain of abc.xml will be retrieved.

After about 20 minutes, running it again, the abc.xml updated will be retrieved?

However, calling to the link to abc.xml on browser (google chrome), the file abc.xml is downloaded with the most recent change. 

Could you please give me an advice on solving this problem?

 

Thanks in advance.

解决方案

You maybe could try to force it by setting the IfModifiedSince property to some time in the past...

Cristian.


这篇关于HttpWebResponse和HttpWebRequest不立即从服务器获取更新文件???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆