This is one of the hidden gems in EPiServer CMS. It basicly allows you to determine if the page is being created by an import (export/import, mirroring) or not (manually, by code). It is done by checking the CurrentITransferContext in your event. We had this problem in Composer and really had some dirty workarounds for it until we had the oppertunity to talk to MagnusS about it and he showed us the way.
Code
public class Global : EPiServer.Global
{
protected void Application_Start(Object sender, EventArgs e)
{
XFormControl.ControlSetup += new EventHandler(XForm_ControlSetup);
EPiServer.DataFactory.Instance.SavingPage += new PageEventHandler(Instance_SavingPage);
}
void Instance_SavingPage(object sender, PageEventArgs e)
{
if (e.Page == null) return;
// If it is null, then this is not an import. If it is an object, it is IMPORTING
if (EPiServer.BaseLibrary.Context.Current["CurrentITransferContext"] != null)
{
// We are creating the page by import
e.Page.PageName += " [created by import]";
}
}
Outcome
If you import a page now, it will have " [created by import]" after the pagename.
