You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.
On our website we import content from another source regularly. When content is imported both language versions of the same page are automatically published back to back with very little time in between. We discovered that when this happens, a redirect-page is erroneously created for the first language version that was published.
In StaticWebInitialization, in the method OnPublishingContent, oldUrl is correct when the first, in our case Swedish, version of the page is published. But when the English version of the same page is published directly after, oldUrl becomes the url of the Swedish version of the page. Because of this, a redirect page is then created for the url to the Swedish page in OnPublishedContent.
We solved this issue on our site by including the language of the published content when getting oldUrl:
private void OnPublishingContent(object sender, ContentEventArgs e)
{
var isPage = e.Content is PageData;
if (isPage)
{
var content = e.Content as PageData;
var staticWebService = ServiceLocator.Current.GetInstance<IStaticWebService>();
var oldUrl = staticWebService.GetPageUrl(new ContentReference(e.Content.ContentLink.ID), content.Language);
e.Items.Add("StaticWeb-OldUrl", oldUrl);
}
}
The text was updated successfully, but these errors were encountered:
Hi!
On our website we import content from another source regularly. When content is imported both language versions of the same page are automatically published back to back with very little time in between. We discovered that when this happens, a redirect-page is erroneously created for the first language version that was published.
In StaticWebInitialization, in the method OnPublishingContent, oldUrl is correct when the first, in our case Swedish, version of the page is published. But when the English version of the same page is published directly after, oldUrl becomes the url of the Swedish version of the page. Because of this, a redirect page is then created for the url to the Swedish page in OnPublishedContent.
We solved this issue on our site by including the language of the published content when getting oldUrl:
The text was updated successfully, but these errors were encountered: