Exemple #1
0
        public bool Handle(RequestContext context)
        {
            System.Uri url    = context.HttpContext.Request.Url;
            string     scheme = url.Scheme;

            Webpage webpage = _getWebpageForRequest.Get(context);

            if (webpage == null)
            {
                return(false);
            }
            if (webpage.RequiresSSL(context.HttpContext.Request, _siteSettings) && scheme != "https")
            {
                string redirectUrl = url.ToString().Replace(scheme + "://", "https://");
                context.HttpContext.Response.RedirectPermanent(redirectUrl);
                return(true);
            }
            if (!webpage.RequiresSSL(context.HttpContext.Request, _siteSettings) && scheme != "http")
            {
                string redirectUrl = url.ToString().Replace(scheme + "://", "http://");
                context.HttpContext.Response.RedirectPermanent(redirectUrl);
                return(true);
            }
            return(false);
        }
        public bool Handle(RequestContext context)
        {
            Webpage webpage = _getWebpageForRequest.Get(context);

            if (webpage == null)
            {
                return(false);
            }
            _standardMrCMSPageExecution.Handle(context, webpage);
            return(true);
        }
Exemple #3
0
        public bool Handle(RequestContext context)
        {
            Webpage webpage = _getWebpageForRequest.Get(context);

            if (webpage == null)
            {
                return(false);
            }
            context.RouteData.MarkAsStandardExecution();
            _standardMaterialCMSPageExecution.Handle(context, webpage);
            return(true);
        }
        public bool Handle(RequestContext context)
        {
            Webpage webpage = _getWebpageForRequest.Get(context);

            if (webpage == null)
            {
                return(false);
            }
            if (webpage == _homePage.Get() && context.HttpContext.Request.Url.AbsolutePath != "/")
            {
                context.HttpContext.Response.Redirect("~/");
                return(true);
            }
            return(false);
        }
Exemple #5
0
        public bool Handle(RequestContext context)
        {
            if (_getWebpage.Get(context) != null)
            {
                return(false);
            }

            Entities.Documents.Web.Webpage webpage = _getWebpageByUrlHistory.Get(context);
            if (webpage == null)
            {
                return(false);
            }

            context.HttpContext.Response.RedirectPermanent("~/" + webpage.LiveUrlSegment);
            return(false);
        }
Exemple #6
0
        public bool Handle(RequestContext context)
        {
            Webpage webpage = _getWebpageForRequest.Get(context);

            if (webpage == null)
            {
                return(false);
            }
            if (!_userUIPermissionsService.IsCurrentUserAllowed(webpage))
            {
                string message = string.Format("Not allowed to view {0}", context.RouteData.Values["data"]);
                int    code    = CurrentRequestData.CurrentUser != null ? 403 : 401;
                _errorHandler.HandleError(context, code, new HttpException(code, message));
                return(true);
            }
            return(false);
        }
        public bool Handle(RequestContext context)
        {
            string path      = context.HttpContext.Request.Url.AbsolutePath;
            string extension = Path.GetExtension(path);

            if (!string.IsNullOrWhiteSpace(extension))
            {
                return(false);
            }
            if (_webpageForRequest.Get(context) == null)
            {
                _errorHandler.HandleError(context, 404,
                                          new HttpException(404, string.Format("Cannot find {0}", context.RouteData.Values["data"])));
                return(true);
            }
            return(false);
        }
        public bool Handle(RequestContext context)
        {
            var path      = context.HttpContext.Request.Url.AbsolutePath;
            var extension = Path.GetExtension(path);

            if (!string.IsNullOrWhiteSpace(extension))
            {
                return(false);
            }
            var webpage = _webpageForRequest.Get(context, Convert.ToString(context.RouteData.Values["data"]).TrimEnd('/'));

            if (webpage == null)
            {
                return(false);
            }

            context.HttpContext.Response.RedirectPermanent("~/" + webpage.LiveUrlSegment);
            return(true);
        }
Exemple #9
0
        public bool Handle(RequestContext context)
        {
            Webpage webpage = _webpageForRequest.Get(context);

            if (webpage is Redirect)
            {
                var    redirect    = (webpage as Redirect);
                string redirectUrl = redirect.RedirectUrl;
                Uri    result;
                if (Uri.TryCreate(redirectUrl, UriKind.Absolute, out result))
                {
                    if (redirect.Permanent)
                    {
                        context.HttpContext.Response.RedirectPermanent(redirectUrl);
                    }
                    else
                    {
                        context.HttpContext.Response.Redirect(redirectUrl);
                    }
                }
                else
                {
                    if (redirectUrl.StartsWith("/"))
                    {
                        redirectUrl = redirectUrl.Substring(1);
                    }

                    if (redirect.Permanent)
                    {
                        context.HttpContext.Response.RedirectPermanent("~/" + redirectUrl);
                    }
                    else
                    {
                        context.HttpContext.Response.Redirect("~/" + redirectUrl);
                    }
                }
                return(true);
            }
            return(false);
        }
Exemple #10
0
        public bool Handle(RequestContext context)
        {
            Uri url = context.HttpContext.Request.Url;

            if (url != null)
            {
                Webpage webpage = _getWebpageForRequest.Get(context);
                if (webpage == null)
                {
                    return(false);
                }
                string scheme    = url.Scheme;
                string authority = url.Authority;
                string baseUrl   = webpage.Site.BaseUrl;
                if (!context.HttpContext.Request.IsLocal && !authority.Equals(baseUrl, StringComparison.InvariantCultureIgnoreCase))
                {
                    string redirectUrl = url.ToString().Replace(scheme + "://" + authority, scheme + "://" + baseUrl);
                    context.HttpContext.Response.Redirect(redirectUrl);
                    return(true);
                }
            }
            return(false);
        }
Exemple #11
0
        public bool Handle(RequestContext context)
        {
            if (_getWebpage.Get(context) != null)
            {
                return(false);
            }

            var webpage = _getWebpageByUrlHistory.Get(context);

            if (webpage == null)
            {
                return(false);
            }

            var queryStringExist = context.HttpContext.Request.QueryString.Count > 0;
            var redirectUrl      = "~/" + webpage.LiveUrlSegment;

            if (queryStringExist)
            {
                redirectUrl += "?" + context.HttpContext.Request.QueryString;
            }
            context.HttpContext.Response.RedirectPermanent(redirectUrl);
            return(false);
        }