【问题标题】:How to get LastModified date of the HttpWebResponse in c#?如何在 c# 中获取 HttpWebResponse 的 LastModified 日期?
【发布时间】:2014-12-07 16:10:15
【问题描述】:

我正在尝试为 windows phone 8.1 创建图像缓存。为此,我需要阅读 HttpWebRequest 的 LastModified 属性。我搜索了谷歌,我发现this,不起作用。我有这个代码:

        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(imageFileUri);
        webRequest.Method="HEAD";
        HttpWebResponse webResponse =  ((HttpWebResponse)await webRequest.GetResponseAsync());

我必须做什么才能得到日期?

【问题讨论】:

    标签: c# http httpwebrequest httpwebresponse system.net.httpwebrequest


    【解决方案1】:

    调试找到解决办法:

     var Date = myHttpWebResponse.Headers["Last-Modified"];
    

    这会返回一个类似的字符串:

         "Mon, 01 Dec 2014 20:00:31 GMT"
    

    【讨论】:

      猜你喜欢
      • 2011-04-22
      • 2022-10-17
      • 2011-03-22
      • 1970-01-01
      • 1970-01-01
      • 2011-06-12
      • 1970-01-01
      • 1970-01-01
      • 2020-02-22
      相关资源
      最近更新 更多