Try our conversational search powered by Generative AI!

PageNotFoundException when creating/deleting pages programmatically.

Vote:
 

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.

Regards
Robert

#56563
Jan 26, 2012 15:50
Vote:
 

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   
    Response.Redirect(BuildURL(newPage));
  }
}
 
#56567
Edited, Jan 26, 2012 16:48
* 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.