CreateNewStandardPage not working in build 1210

Posted by Community Admin on 03-Aug-2018 20:42

CreateNewStandardPage not working in build 1210

All Replies

Posted by Community Admin on 08-Mar-2011 00:00

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.

Posted by Community Admin on 09-Mar-2011 00:00

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

Posted by Community Admin on 14-Mar-2011 00:00

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.

Posted by Community Admin on 23-Mar-2011 00:00

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

This thread is closed