Esempio n. 1
0
        private void handleEndRequest(object sender, EventArgs e)
        {
            if (!initialized || 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;
        }