예제 #1
0
        /// <summary>
        /// Set content headers
        /// </summary>
        /// <param name="context">Controller context</param>
        /// <param name="response">Response</param>
        protected override void SetContentHeaders(ControllerContext context, HttpResponseBase response)
        {
            // Call base method
            base.SetContentHeaders(context, response);

            // Get info
            var lastModified = CommandResult.File.LastWriteTimeUtc;
            var fileName     = CommandResult.File.Name;
            var eTag         = GetFileETag(fileName, lastModified);

            // Get if file is considered modified
            if (HttpCacheHelper.ReturnNotModified(eTag, lastModified, context))
            {
                // Not modified
                response.StatusCode        = (int)HttpStatusCode.NotModified;
                response.StatusDescription = "Not Modified";
                response.AddHeader("Content-Length", "0");
                response.Cache.SetCacheability(HttpCacheability.Public);
                response.Cache.SetLastModified(lastModified);
                response.Cache.SetETag(eTag);
            }
            else
            {
                // Modified
                response.Headers["ETag"]          = eTag;
                response.Headers["Last-Modified"] = lastModified.ToString("R");
            }
        }
예제 #2
0
 public IActionResult GetThumbnail(HttpRequest request, HttpResponse response, string hash)
 {
     if (hash != null)
     {
         var path = driver.ParsePath(hash);
         if (!path.IsDirectory && path.Root.CanCreateThumbnail(path.File))
         {
             if (!HttpCacheHelper.IsFileFromCache(path.File, request, response))
             {
                 ImageWithMimeType thumb = path.Root.GenerateThumbnail(path);
                 return(new FileStreamResult(thumb.ImageStream, thumb.MimeType));
             }
             else
             {
                 response.ContentType = Utils.GetMimeType(path.Root.PicturesEditor.ConvertThumbnailExtension(path.File.Extension));
                 //response.End();
             }
         }
     }
     return(new EmptyResult());
 }
예제 #3
0
        //获取用户代码中的配置
        static UserCfg GetUserConfigItem()
        {
            UserCfg userCfg = new HttpCacheHelper().GetCache(AppConfig.GetCacheKey(CacheConst.userCfgInCode)) as UserCfg;

            return(userCfg);
        }