Пример #1
0
        private bool handleErrorIfOnHandledErrorPage(string errorEvent, Exception exception)
        {
            var handledErrorPages = new List <PageInfo>
            {
                MetaLogicFactory.CreateAccessDeniedErrorPageInfo(false),
                MetaLogicFactory.CreatePageDisabledErrorPageInfo(""),
                MetaLogicFactory.CreatePageNotAvailableErrorPageInfo(false)
            };

            if (handledErrorPages.All(p => getErrorPage(p).GetUrl().Separate("?", false).First() != RequestState.Url.Separate("?", false).First()))
            {
                return(false);
            }
            RequestState.SetError(errorEvent + " during a request for a handled error page" + (exception != null ? ":" : "."), exception);
            transferRequest(getErrorPage(MetaLogicFactory.CreateUnhandledExceptionErrorPageInfo()), true);
            return(true);
        }
Пример #2
0
        private bool handleErrorIfOnHandledErrorPage(string errorEvent, Exception exception)
        {
            var handledErrorPages = new[]
            {
                MetaLogicFactory.CreateAccessDeniedErrorPageInfo(false), MetaLogicFactory.CreatePageDisabledErrorPageInfo(""),
                MetaLogicFactory.CreatePageNotAvailableErrorPageInfo(false)
            }.Select(getErrorPage);
            var requestParameters = new HashSet <string>(getQueryParameters(RequestState.Url));

            if (handledErrorPages.All(
                    page => page.GetUrl().Separate("?", false).First() != RequestState.Url.Separate("?", false).First() ||
                    getQueryParameters(page.GetUrl()).Any(i => !requestParameters.Contains(i))))
            {
                return(false);
            }
            RequestState.SetError(errorEvent + " during a request for a handled error page" + (exception != null ? ":" : "."), exception);
            transferRequest(getErrorPage(MetaLogicFactory.CreateUnhandledExceptionErrorPageInfo()), true);
            return(true);
        }
Пример #3
0
        private void handleEndRequest(object sender, EventArgs e)
        {
            if (!FrameworkInitialized || RequestState == null)
            {
                return;
            }

            ExecuteWithBasicExceptionHandling(
                delegate {
                try {
                    // This 404 condition covers two types of requests:
                    // 1. Requests where we set the status code in handleError
                    // 2. Requests to handlers that set the status code directly instead of throwing exceptions, e.g. the IIS static file handler
                    if (Response.StatusCode == 404 && !handleErrorIfOnErrorPage("A status code of 404 was produced", null))
                    {
                        transferRequest(getErrorPage(MetaLogicFactory.CreatePageNotAvailableErrorPageInfo(!RequestState.HomeUrlRequest)), false);
                    }

                    if (RequestState.TransferRequestPath.Length > 0)
                    {
                        // NOTE: If we transfer to a path with no query string, TransferRequest adds the current query string. Because of this bug we need to make sure all
                        // pages we transfer to have at least one parameter.
                        Server.TransferRequest(RequestState.TransferRequestPath, false, "GET", null);
                    }
                }
                catch {
                    RequestState.RollbackDatabaseTransactions();
                    DataAccessState.Current.ResetCache();
                    throw;
                }
            },
                true,
                true);

            // Do not set a status code since we may have already set one or set a redirect page.
            ExecuteWithBasicExceptionHandling(delegate { RequestState.CleanUp(); }, false, false);
            RequestState = null;
        }