Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search Engine Sitemap Settings returns 404 - Language Fallback issue #150

Open
trouden opened this issue Apr 2, 2021 · 0 comments
Open

Comments

@trouden
Copy link

trouden commented Apr 2, 2021

Our setup is as follows:

  • Website 1 - which exists in 'en'
  • Website 2 - which exists in 'nl' & 'fr' - domain is not mapped to a language, browserlanguage is used to determine the language when visiting the homepage of the domain, any other page has the language in the url.
  • Globalization cultures are set to 'nl'
  • Browserlanguage is set to 'en'

.Net Framework 4.7.2
Episerver.CMS 11.20.5
Episerver.Commerce 13.30
Geta.SEO.Sitemaps 4.0.0
Geta.SEO.Sitemaps.Commerce 4.0.0

When using the domain of website 2 and trying to configure the search engine sitemap settings we receive a 404. When using the domain of website 1 everything works fine.

This all is due to the AdminManageSiteMap inheriting from the SimplePage class, which inherits from the PageBase. I do not know why this is the case, as the settings page is not a real episerver page.

In the OnInit(EventArgs e) method of the PageBase cache policies are being set in this.SetCachePolicy();

The method does the following:

protected virtual void SetCachePolicy() => this.Locate.Advanced.GetInstance<OutputCacheHandler>().SetCachePolicy(PrincipalInfo.CurrentPrincipal, (ContentReference) this.CurrentPageLink, (HttpContextBase) new HttpContextWrapper(this.Context), Settings.Instance, this.CurrentPage != null ? this.CurrentPage.StopPublish : new DateTime?(DateTime.MaxValue));

Here the issue is the CurrentPage is being called, this is resolved by the LoadCurrentPage class which does the following:

    public virtual PageData CurrentPage
    {
      get
      {
        if (this._pageData == null && PageReference.IsValue(this.Page.CurrentPageLink))
        {
          LoaderOptions loaderOptions = new LoaderOptions();
          loaderOptions.Add<LanguageLoaderOption>(this.EnableMasterLanguageFallback ? LanguageLoaderOption.FallbackWithMaster() : LanguageLoaderOption.Fallback());
          this._pageData = this.Page.GetPage(this.Page.CurrentPageLink, loaderOptions);
          if (this._pageData == null || !this.EnableLoadPageWithoutTemplate && !ServiceLocator.Current.GetInstance<TemplateResolver>().HasPageTemplate(this._pageData) || !this.IsRoutable(this._pageData))
          {
            this.Page.Response.Clear();
            ExceptionManager.RenderHttpRuntimeError((Exception) new HttpException(404, "Not Found"));
            this.Page.Response.End();
          }
        }
        return this._pageData;
      }
      set => this._pageData = value;
    }

It tries to retrieve the CurrentPageLink without MasterLanguageFallback, the CurrentPageLink points to the HomePage of the site since AdminManageSiteMap is not a real EpiServer page. Which in our case fails since as mentioned at the beginning browserlanguage is used since no language is included in the path, which in our case is 'en'. The site does not exist in 'en' and so a 404 is returned. This all happens without any error logging so is quite a mystery when we encoutered this at first.

This is related to the issue which was encoutered in #32, except there it was with this.ValidatePageTemplate() which is called later in the OnInit(EventArgs e) method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant