More in this section

Forums / General Discussions / CreateNewStandardPage not working in build 1210

CreateNewStandardPage not working in build 1210

4 posts, 0 answered
  1. Phil
    Phil avatar
    89 posts
    Registered:
    19 Oct 2010
    08 Mar 2011
    Link to this post
    We upgraded from build 1098 to build 1210.  The following block of code was running fine for weeks, but immediately after the upgrade it throws the error: Object reference not set to an instance of an object.
    I stopped the code in debug and verified that all the variables that are being used in the method chain are valid and not null.
    fluent.CreateNewStandardPage(parentNode)
        .Do(pn =>
        {
            pn.Title = newPageName;      
            pn.UrlName = newPageName; 
            pn.Page.Title = newPageName; 
            pn.InheritsPermissions = myInheritPermissions;
        })
        .CheckOut() 
        .SetTemplateTo(guidTemplate)
        .Publish()
        .SaveChanges();

    Here is the top of the stack trace.  The method, MyPageManager.MakeNewPage()  is mine.
    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Sitefinity.Modules.Pages.PageManager.ExecutePublishPageDraft(PageDraft draft, Boolean makeVisible) +1309
       Telerik.Sitefinity.Modules.Pages.PageManager.PublishPageDraft(PageDraft draft, Boolean makeVisible) +669
       Telerik.Sitefinity.Fluent.Pages.PageDraftFacade.Publish() +251
       LessonBuilder.Web.Util.MyPageManager.MakeNewPage(String mainPageName, Boolean isChildToThis, String childPageName, Boolean myInheritPermissions) in C:\CurrentFiles\Projects\LessonBuilder1098\LessonBuilderApp\LessonBuilder.Web\Util\myPageManager.cs:170

    Can you verify that this is a problem on your side?  If not please advise me what I am doing wrong.
    Thanks.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 Mar 2011
    Link to this post
    Hi Phil,

    This code

    var pageTemplate = PageManager.GetManager().GetTemplates().First();
               var pageFacade = App.WorkWith().Page().CreateNewStandardPage(PageLocation.Frontend).Do(pg =>
               {
                   pg.Name = "name";
                   pg.Title = "title";
                   pg.UrlName = "someurlname";
                   pg.ShowInNavigation = true;
                   pg.Page.Title = "datatitle";
                   pg.Page.HtmlTitle = "htmldatatitle";
                   pg.Description = "Some description";
                 })
                 .CheckOut()
                 .SetTemplateTo(pageTemplate)
                 .Publish()
                .SaveChanges();

    works fine under SP1.

    All the best,
    Ivan Dimitrov
    the Telerik team
  3. Richard Baugh
    Richard Baugh avatar
    201 posts
    Registered:
    22 Aug 2012
    14 Mar 2011
    Link to this post
    Ivan,
        I am also getting this same error in SP1. Here is the code that I am using:

    PageManager manager = PageManager.GetManager();
    var template = manager.GetTemplates().First();
     
    var newPage = App.WorkWith().Page()
                    .CreateNewStandardPage(PageLocation.Frontend)
                    .Do(p=>{
                        p.Name = "FluentAPI Page";
                        p.Title = "Fluet API Page";
                        p.UrlName = "fluent-api-page";
                        p.ShowInNavigation = true;
                        p.Page.Title = "Fluent API Page";
                    })
                    .CheckOut()
                    .SetTemplateTo(template)
                    .Publish()
                    .SaveChanges();

    If I take out the ".Publish()" statement, then the code will run and my page is checked out. After deleting the page and adding the ".Publish()" back in, I again get the error. My Stacktrace is the same.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Mar 2011
    Link to this post
    Hello Richard,

    I am not able to replicate this issue using the SP1 and latest internal build. The code creates a new page.

    Greetings,
    Ivan Dimitrov
    the Telerik team
4 posts, 0 answered