More in this section

Forums / Developing with Sitefinity / Renaming page via API

Renaming page via API

2 posts, 1 answered
  1. Gokhan
    Gokhan avatar
    32 posts
    11 Jul 2008
    14 Sep 2009
    Link to this post

    Following code snippet is ending with runtime error. When i try to change the name of page via CMS API?

      CmsManager cmsManager = new CmsManager();
            Telerik.Cms.ICmsPage projectPage = cmsManager.GetPage(PageId, true) as Telerik.Cms.ICmsPage;

            projectPage.MenuName = "test title";
            projectPage.Navigable = true;
            projectPage.Description = "ddd";
            projectPage.Name = "newpagename";
            projectPage.Title = "ssss";
            projectPage.Keywords = "keywords";
            projectPage.DenyIndexing = false;
            projectPage.DenyAnonymous = false;
            projectPage.RequireCaching = true;
            projectPage.DisableViewState = false;
            projectPage.DenyIndexing = true;

            //TODO:  Allow head tags and links to be saved 




    An item with the same key has already been added.

    Description:An unhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about the error andwhere it originated in the code.

    Exception Details:System.ArgumentException: An item with the same key has already beenadded.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [ArgumentException: An item with the same key has already been added.]   System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +51   System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +2644753   System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) +21   Telerik.Cms.Web.CmsSiteMapProvider.CacheNode(ICmsPage page, CmsSiteMapNode parentNode) +1499   Telerik.Cms.Web.CmsSiteMapProvider.GetUrlContext(String url, Boolean skipSvcs, Boolean skipMappingService) +1590   Telerik.Cms.Web.CmsSiteMapProvider.GetUrlContext(String url, Boolean skipSvcs) +59   Telerik.Cms.Web.UrlHelper.GetUrl(String url, Boolean skipSvcs) +67   Telerik.Cms.Web.UrlHelper.GetUrl(String url) +33   Telerik.Cms.Web.CmsHttpModule.BeginRequest(Object sender, EventArgs e) +4374   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    14 Sep 2009
    Link to this post
    Hi Gokhan,

    Below is a sample code that illustrates renaming of a CMS page.

            var manager = new CmsManager(); 
            IList listofAllpage = manager.GetPages(); 
            foreach (ICmsPage cmsPage in listofAllpage) 
                if (cmsPage.Name == "rename"
                    string pageId = cmsPage.ID.ToString(); 
                    ICmsPage ourPage = manager.GetPage(cmsPage.ID, trueas ICmsPage; 
                        ourPage.Name = "RenamedPage"

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 1 answered