private static bool PermissionDenied(MediaRequestHandlerArgs handlerArgs)
 {
     using (new SecurityDisabler())
     {
         handlerArgs.Media = MediaManager.GetMedia(handlerArgs.Request.MediaUri);
     }
     return(handlerArgs.Media != null);
 }
예제 #2
0
        protected override bool DoProcessRequest(HttpContext context)
        {
            var mediaRequestHandlerArgs = new MediaRequestHandlerArgs(context);

            CorePipeline.Run("mediaRequestHandler", mediaRequestHandlerArgs, failIfNotExists: false);
            if (mediaRequestHandlerArgs.Aborted)
            {
                return(mediaRequestHandlerArgs.Result);
            }
            return(new MediaRequestHandler().DoProcessRequest(mediaRequestHandlerArgs.Context, mediaRequestHandlerArgs.Request, mediaRequestHandlerArgs.Media));
        }
예제 #3
0
        protected override bool DoProcessRequest(HttpContext context)
        {
            var mediaRequestHandlerArgs = new MediaRequestHandlerArgs(context);

            CorePipeline.Run("mediaRequestHandler", mediaRequestHandlerArgs, failIfNotExists: false);
            if (mediaRequestHandlerArgs.Aborted)
            {
                return(mediaRequestHandlerArgs.Result);
            }
            if (context?.Request.QueryString?["extension"] == "webp" || (!Helpers.CdnEnabled && context.BrowserSupportsWebP()))
            {
                mediaRequestHandlerArgs.Request.Options.CustomOptions["extension"] = "webp";
            }
            return(DoProcessRequest(mediaRequestHandlerArgs.Context, mediaRequestHandlerArgs.Request, mediaRequestHandlerArgs.Media));
        }
예제 #4
0
        public override void Process(MediaRequestHandlerArgs handlerArgs)
        {
            if (handlerArgs.Media != null)
            {
                return;
            }

            var notFoundUrl = GetNotFoundUrl();

            if (string.IsNullOrWhiteSpace(notFoundUrl))
            {
                return;
            }

            var httpServer = _httpServerThunk();

            httpServer.TransferRequest(notFoundUrl);
            handlerArgs.Result = true;
            handlerArgs.AbortPipeline();
        }
        public override void Process(MediaRequestHandlerArgs handlerArgs)
        {
            if (handlerArgs.Media != null)
            {
                return;
            }
            if (!PermissionDenied(handlerArgs))
            {
                return;
            }

            var loginUrl = GetLoginUrl();

            if (string.IsNullOrWhiteSpace(loginUrl))
            {
                return;
            }

            var httpResponse = _httpResponseThunk();

            httpResponse.Redirect(loginUrl);
            handlerArgs.Result = true;
            handlerArgs.AbortPipeline();
        }