Try our conversational search powered by Generative AI!

Programmatically created page not visible in edit mode with multiple sites


Hi! I have two sites in the same EPiServer instance. I'm writing an admin plugin that takes some properties from a page on the first site and creates a page on the second from that information (a mobile version of the first page). The problem is that the newly created page is not visible in the second site until I recompile everything, which makes me think that it is a caching issue. If I run the admin plugin from the second site the change is reflected immediately. I've tried to remove the start page on the second site from cache by calling DataFactoryCache.RemovePage when creating the page but to no success. Does anyone know how to make the second site refresh if I run the plugin from the first site? Cheers!

Aug 05, 2011 13:10

Hi Christer

Could you post the code you're using to create the page on the other site?


Aug 06, 2011 11:54

Here it comes:

fullProjectPageID = //ID of existing page;
MobileStartPage = //Root node of second site; 

PageData projectStartPage = DataFactory.Instance.GetPage(new PageReference(fullProjectPageID)); 

PageData generatedPage = DataFactory.Instance.GetDefaultPageData(MobileStartPage, MobileProjectPageType.PageTypeID);

generatedPage.PageName = DataFactory.Instance.GetPage(projectStartPage.ParentLink).PageName;

generatedPage["FullProjectPage"] = projectStartPage.PageLink;

generatedPage["PageHeading"] = projectStartPage["PageHeading"];

//etc for all properties

foreach (PageData sibling in DataFactory.Instance.GetChildren(projectStartPage.ParentLink))
    if (sibling.PageName.Equals("Bilder"))
             generatedPage["ImageAlbum"] = sibling["ProjectImageAlbum"];

DataFactory.Instance.Save(generatedPage, EPiServer.DataAccess.SaveAction.Publish);

/* I've tried adding DataFactoryCache.RemovePage(MobileStartPage) here but the result is the same */

Aug 08, 2011 9:58

Do you use more than one front web server in this setup? Are you serving the mobile web site from a different front web server perhaps? In that case it's probably the cache synchronization between servers that isn't working.

Aug 08, 2011 12:03

We do have a load balanced environment yes, but in this case I'm still on my development machine running a local IIS instance in Windows Vista.

Aug 08, 2011 13:01

And these sites are both served by the same Application in IIS?

Aug 08, 2011 13:59

They use the same AppPool yes, and they are both visible in the same EPiServer UI. However, I cannot log in to the second site in IE due to an exception: "This request has probably been tampered with. Close the browser and try again." In Google Chrome it works. Perhaps this has something to do with it?

Aug 08, 2011 14:05

The same App pool is one thing, but are they the same app = site in IIS? I'm thinking you have two apps pointing to the same directory? In that case they won't share memory and they will have to be cache-synchronized in the same way as load-balanced applications (as they "share" content).

Aug 08, 2011 14:18

That must be it! I've deleted the second site in IIS and just added it as a binding to the first. However, this produces the error message Application is initialized with settings for siteId="X", but current request maps to siteId="Y". I guess I have to set up remote events on my developer machine and use two apps in IIS. Thanks for the help!!

Aug 08, 2011 15:37
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.