Exemplo n.º 1
0
        private bool TryProcessRequestFromCache(HttpResponse response)
        {
            bool retVal = false;

            byte[] imageBytes = ImageCacheBroker.GetImageBytes();
            if (imageBytes != null && imageBytes.Length > 0)
            {
                response.ContentType = ImageMetadata.ContentType;
                response.AppendHeader("Content-Disposition", string.Concat("inline; filename=\"", ImageMetadata.SaveName, "\""));
                response.AppendHeader("Content-Length", imageBytes.Length.ToString(CultureInfo.InvariantCulture));
                response.Cache.SetCacheability(HttpCacheability.Public);
                response.Cache.SetAllowResponseInBrowserHistory(true);
                response.Cache.SetLastModified(ImageMetadata.LastModifiedDate);
                response.Cache.SetValidUntilExpires(true);
                response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(ImageSettings.ClientCacheTimeout));

                response.OutputStream.Write(imageBytes, 0, imageBytes.Length);
                retVal = true;
            }

            return(retVal);
        }