记录在案here HttpWebResponse 类的 LastModified 属性:
contains the value of the Last-Modified header received with the response
根据此处和在线其他页面上的一些其他答案(例如 here):
It's completely up to the server if it sets the Last-Modified response header
如果服务器未设置此 header ,我应该期望该属性的值在 .Net 中是什么?日期时间.MinValue?日期时间。现在?或者是否有其他方法可以检测服务器是否设置了此 header ?
最佳答案
如果您查看 HttpWebResponse 的源代码您会看到,如果服务器未设置 Last-Modified header ,则返回 DateTime.Now
。
为了确定响应中是否存在 header 值,您可以使用 HttpWebResponse.GetResponseHeader方法。例如
var isLastModifiedSent = !string.IsNullOrEmpty(webResponse.GetResponseHeader("Last-Modified"));
关于c# - HttpWebResponse.LastModified 的默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42577127/