PageNotFoundException when creating/deleting pages programmatically.

We have this calendar function where users can create calendar events from “browser mode”.
When the user hits “add new”. The event page is created programmatically under a container and a redirect to this page is executed. After the user has edited dates etc. He hits save and the page is copied to its proper location and then deleted under the container. Problem occurs (occasionally) when a user immediately after saving and then presses the “add new” button again to add yet another event. Result sometimes in the “EPiServer.Core.PageNotFoundException”. It’s like the cache mechanism does not keep up. Because if one waits for like 5 seconds before pressing “add new” the second time, this issue doesn’t occur.

Appreciate any thoughts on this.


#56563 Jan 26, 2012 15:50
  • My question is why the new page under container gets fetched from cache (the page that is deleted when user hits "save") Thought I allways was creating new one?

    From user control.
    --- When user hits the “add new” button ---

    protected void linkbtnCreateNew_Click(object sender, EventArgs e)
      if (IsValue("ContainerPage") && IsValue("EventItem_PageType"))
        PageReference prefNewPageParent =  PageReference.Parse(CurrentPage.Property["ContainerPage"].Value.ToString());
        PageData newPage;
        int pagetypeID = Convert.ToInt32(CurrentPage["EventItem_PageType"].ToString());
        PageData page = DataFactory.Instance.GetDefaultPageData(prefNewPageParent, pagetypeID);
        newPage = page.CreateWritableClone();
        newPage.PageName = "Heading";
        DataFactory.Instance.Save(newPage, EPiServer.DataAccess.SaveAction.Publish, AccessLevel.NoAccess);
        newPage.LinkURL = PageBase.BuildUrlWithPageReference(newPage.LinkURL, newPage.PageLink);
        //Redirect to editable page   
    #56567 Edited, Jan 26, 2012 16:48