Esempio n. 1
0
 public FrontHtmlHelper(Page_Context context, HtmlHelper html, ViewRender viewRender, ProxyRender proxyRender)
 {
     this.PageContext = context;
     this.Html        = html;
     this.ViewRender  = viewRender;
     this.ProxyRender = proxyRender;
 }
Esempio n. 2
0
        protected override void OnException(ExceptionContext filterContext)
        {
            HttpErrorStatusCode statusCode    = HttpErrorStatusCode.InternalServerError_500;
            HttpException       httpException = filterContext.Exception as HttpException;

            if (httpException != null)
            {
                statusCode = (HttpErrorStatusCode)httpException.GetHttpCode();
            }
            if (statusCode == HttpErrorStatusCode.NotFound_404)
            {
                ProxyRender proxyRender  = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve <ProxyRender>();
                var         actionResult = proxyRender.TryRemoteRequest(filterContext.Controller.ControllerContext);
                if (actionResult != null)
                {
                    filterContext.Result           = actionResult;
                    filterContext.ExceptionHandled = true;
                }
            }
            if (filterContext.ExceptionHandled == false)
            {
                if (Site != null)
                {
                    var customError = Services.ServiceFactory.CustomErrorManager.Get(Site, statusCode.ToString());

                    if (customError != null)
                    {
                        var errorUrl = customError.RedirectUrl;

                        if (!string.IsNullOrEmpty(errorUrl) && !errorUrl.TrimStart('~').TrimStart('/').TrimEnd('/').EqualsOrNullEmpty(this.Request.AppRelativeCurrentExecutionFilePath.TrimStart('~').TrimStart('/').TrimEnd('/'), StringComparison.OrdinalIgnoreCase))
                        {
                            filterContext.Result           = RedirectHelper.CreateRedirectResult(Site, FrontHttpRequest.RequestChannel, errorUrl, Request.RawUrl, (int)statusCode, customError.RedirectType, customError.ShowErrorPath);
                            filterContext.ExceptionHandled = true;
                        }
                    }
                }
                else
                {
                    if (statusCode == HttpErrorStatusCode.NotFound_404)
                    {
                        filterContext.Result           = RedirectTo404();
                        filterContext.ExceptionHandled = true;
                    }
                }
                Kooboo.HealthMonitoring.Log.LogException(filterContext.Exception);
            }

            base.OnException(filterContext);
        }