Show301Message() public static method

public static Show301Message ( string sFileRequested ) : void
sFileRequested string
return void
        public void ProcessRequest(HttpContext context)
        {
            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                SiteNav navData        = null;
                string  sFileRequested = context.Request.Path;
                sRequestedURL = sFileRequested;
                string sScrubbedURL = sFileRequested;

                sRequestedURL = SiteData.AppendDefaultPath(sRequestedURL);

                try {
                    sScrubbedURL = SiteData.AlternateCurrentScriptName;

                    if (sScrubbedURL.ToLower() != sRequestedURL.ToLower())
                    {
                        sFileRequested = sScrubbedURL;
                        bURLOverride   = true;
                    }

                    VirtualDirectory.RegisterRoutes();
                } catch (Exception ex) {
                    //assumption is database is probably empty / needs updating, so trigger the under construction view
                    if (DatabaseUpdate.SystemNeedsChecking(ex) || DatabaseUpdate.AreCMSTablesIncomplete())
                    {
                        if (navData == null)
                        {
                            navData = SiteNavHelper.GetEmptyHome();
                        }
                    }
                    else
                    {
                        //something bad has gone down, toss back the error
                        throw;
                    }
                }

                sFileRequested = SiteData.AppendDefaultPath(sFileRequested);

                if (context.User.Identity.IsAuthenticated)
                {
                    try {
                        if (context.Request.UrlReferrer != null && !string.IsNullOrEmpty(context.Request.UrlReferrer.AbsolutePath))
                        {
                            if (context.Request.UrlReferrer.AbsolutePath.ToLower().Contains(FormsAuthentication.LoginUrl.ToLower()) ||
                                FormsAuthentication.LoginUrl.ToLower() == sFileRequested.ToLower())
                            {
                                if (SiteFilename.DashboardURL.ToLower() != sFileRequested.ToLower() &&
                                    SiteFilename.SiteInfoURL.ToLower() != sFileRequested.ToLower())
                                {
                                    sFileRequested = SiteData.AdminDefaultFile;
                                }
                            }
                        }
                    } catch (Exception ex) { }
                }

                if (sFileRequested.ToLower().EndsWith(".aspx") || SiteData.IsLikelyHomePage(sFileRequested))
                {
                    bool bIgnorePublishState = SecurityData.AdvancedEditMode || SecurityData.IsAdmin || SecurityData.IsSiteEditor;

                    string queryString = String.Empty;
                    queryString = context.Request.QueryString.ToString();
                    if (string.IsNullOrEmpty(queryString))
                    {
                        queryString = String.Empty;
                    }

                    if (!CMSConfigHelper.CheckRequestedFileExistence(sFileRequested, SiteData.CurrentSiteID) || SiteData.IsLikelyHomePage(sFileRequested))
                    {
                        context.Items[REQ_PATH]  = context.Request.PathInfo;
                        context.Items[REQ_QUERY] = context.Request.QueryString.ToString();

                        // handle a case where this site was migrated from a format where all pages varied on a consistent querystring
                        // allow this QS parm to be set in a config file.
                        if (SiteData.IsLikelyHomePage(sFileRequested))
                        {
                            string sParm = String.Empty;
                            if (SiteData.OldSiteQuerystring != string.Empty)
                            {
                                if (context.Request.QueryString[SiteData.OldSiteQuerystring] != null)
                                {
                                    sParm = context.Request.QueryString[SiteData.OldSiteQuerystring].ToString();
                                }
                            }
                            if (!string.IsNullOrEmpty(sParm))
                            {
                                sFileRequested = "/" + sParm + ".aspx";

                                SiteData.Show301Message(sFileRequested);

                                context.Response.Redirect(sFileRequested);
                                context.Items[REQ_PATH]  = sFileRequested;
                                context.Items[REQ_QUERY] = String.Empty;
                            }
                        }

                        try {
                            //periodic test of database up-to-dated-ness
                            if (DatabaseUpdate.TablesIncomplete)
                            {
                                navData = SiteNavHelper.GetEmptyHome();
                            }
                            else
                            {
                                bool bIsHomePage = false;

                                if (SiteData.IsLikelyHomePage(sFileRequested))
                                {
                                    navData = navHelper.FindHome(SiteData.CurrentSiteID, !bIgnorePublishState);

                                    if (SiteData.IsLikelyHomePage(sFileRequested) && navData != null)
                                    {
                                        sFileRequested = navData.FileName;
                                        bIsHomePage    = true;
                                    }
                                }

                                if (!bIsHomePage)
                                {
                                    string pageName = sFileRequested;
                                    navData = navHelper.GetLatestVersion(SiteData.CurrentSiteID, !bIgnorePublishState, pageName);
                                }

                                if (SiteData.IsLikelyHomePage(sFileRequested) && navData == null)
                                {
                                    navData = SiteNavHelper.GetEmptyHome();
                                }
                            }
                        } catch (Exception ex) {
                            //assumption is database is probably empty / needs updating, so trigger the under construction view
                            if (DatabaseUpdate.SystemNeedsChecking(ex) || DatabaseUpdate.AreCMSTablesIncomplete())
                            {
                                if (navData == null)
                                {
                                    navData = SiteNavHelper.GetEmptyHome();
                                }
                            }
                            else
                            {
                                //something bad has gone down, toss back the error
                                throw;
                            }
                        }

                        if (navData != null)
                        {
                            string sSelectedTemplate = navData.TemplateFile;

                            // selectivly engage the cms helper only if in advance mode
                            if (SecurityData.AdvancedEditMode)
                            {
                                using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) {
                                    if (cmsHelper.cmsAdminContent != null)
                                    {
                                        try { sSelectedTemplate = cmsHelper.cmsAdminContent.TemplateFile.ToLower(); } catch { }
                                    }
                                }
                            }

                            if (!CMSConfigHelper.CheckFileExistence(sSelectedTemplate))
                            {
                                sSelectedTemplate = SiteData.DefaultTemplateFilename;
                            }

                            sVirtualReqFile = sFileRequested;

                            if (bURLOverride)
                            {
                                sVirtualReqFile = sRequestedURL;
                                sFileRequested  = sRequestedURL;
                            }

                            RewriteCMSPath(context, sSelectedTemplate, queryString);
                        }
                        else
                        {
                            SiteData.PerformRedirectToErrorPage(404, sFileRequested);
                            SiteData.Show404MessageFull(true);
                        }
                    }
                    else
                    {
                        sVirtualReqFile = sFileRequested;

                        RewriteCMSPath(context, sVirtualReqFile, queryString);
                    }
                }

                context.ApplicationInstance.CompleteRequest();
            }
        }