【发布时间】:2011-07-15 02:45:32
【问题描述】:
我有两个约会时间。 我从 sql server 获取的一个日期时间,另一个日期是客户端的日期时间。
两个日期时间相等,但在我的代码中返回不相等。 为什么?
var mngProduct = new ProductManager();
var file = mngProduct.GetProductImageData(int.Parse(context.Request["imageId"]), imageSize);
if (!String.IsNullOrEmpty(context.Request.Headers["If-Modified-Since"]))
{
System.Globalization.CultureInfo provider = System.Globalization.CultureInfo.InvariantCulture;
var lastMod = DateTime.ParseExact(context.Request.Headers["If-Modified-Since"], "r", provider).ToLocalTime();
if (lastMod==file.CreatedOn)//return false always
{
res.StatusCode = 304;
res.StatusDescription = "Not Modified";
return;
}
}
res.ContentType = file.MimeType;
res.AddHeader("Content-disposition", "attachment; filename=" + file.FileName);
res.AddHeader("Content-Length", file.Content.Length.ToString());
res.BinaryWrite(file.Content.ToArray());
res.Cache.SetCacheability(HttpCacheability.Public);
res.Cache.SetLastModified(file.CreatedOn);
【问题讨论】:
-
您确定要比较同一时区设置中的日期时间值吗?
标签: c# .net sql-server datetime