I have two times. One day I get from sql server and another date is the date and time of the client.
Two days of life are equal, but they are not equal in my return code. Why?
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)
{
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);
source
share