Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Difference between create a new page or copy an existing page


Hi everyone,

I'm using the CreatedContent event and trying to check if the created page is a brand new page or just a page created by Copy-Paste of an existing page. How can i spot the difference in code between the two?

Thanks in advance,


Apr 05, 2016 12:37


Try to execute safety cast eventArgs to CopyContentEventArgs:

bool isCopy = eventArgs as CopyContentEventArgs;
Edited, Apr 05, 2016 13:18

I can't get that to work.

I link event with:

contentEvents.CreatedContent += contentEvents_CreatedContent;
public void contentEvents_CreatedContent(object sender, EPiServer.ContentEventArgs e)

Apr 05, 2016 13:25


I just tested it on Alloy demo and it works:

using EPiServer.Core;
using EPiServer.Framework;
using EPiServer.SpecializedProperties;
using ContentAreaWithPreview.Business.WebControls;
using EPiServer;
using EPiServer.Framework.Initialization;
using EPiServer.Logging;
using EPiServer.ServiceLocation;

namespace ContentAreaWithPreview.Business.Initialization
    public class TestInitialization : IInitializableModule
        public void Initialize(InitializationEngine context)
            var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
            contentEvents.CreatedContent += ClassFactoryInitialization_CreatedContent;

        private static readonly ILogger _logger = LogManager.GetLogger();
        private void ClassFactoryInitialization_CreatedContent(object sender, EPiServer.ContentEventArgs e)
            var copyContentEventArgs = e as CopyContentEventArgs;
            if (copyContentEventArgs != null)
                _logger.Debug("Copy content from {0}...", copyContentEventArgs.SourceContentLink);

        public void Uninitialize(InitializationEngine context) { }

During copying the event is executed few times.

Apr 07, 2016 9:11


I added the code, but the 'copyContentEventArgs' variable still returns a null-value after a copy/paste action.

Thanks for checking it,


Apr 08, 2016 10:50

3 Years later..... but i have the same issue.  i'm trying to initialize some field in the CreatedContent when a user copy/paste a page.  Maybe it's not THE place to do this operation....  But my CopyContentEventArgs is always null. and impossible to update values since everything except the PageName seem to be null.....

Any help would be highly appreciated! Thanks,

Oct 09, 2019 16:58

Hi Christian,

I have tested above code and verified that, and it is working for me too, you just need to get item with content loader as PageData to read any property.

I copied and pasted Alloy Plan page.

Here you can see full list of data loaded in debug mode

Oct 09, 2019 19:21

Thanks for you reply!,

but this is strange... on my side, CopyContentEventArgs is always null...

Oct 09, 2019 20:18

So, it hits multiple times in ClassFactoryInitialization_ContentCreated method. You need to hit until you get into if condition. Is that not going into if statement for you when you paste your copied page? 

If that's the case, I would like to know if you are testing in Alloy or other project? I will confirm if I also face that in other project.

Oct 09, 2019 20:50

ohhh, got it.  We are a couple of developers on the same azure service bus (Dev environment). And i think maybe the problem was due to multiple dev debugging at the same time... anyway, it working! 

Thanks a lot Praful

Oct 09, 2019 21:40

Sounds good, now you can mark Grzegorz's answer accepted. That will help other developers find solution to similar problems. :)

Edited, Oct 09, 2019 22:20
* 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.