Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Max Mumford 266 posts 293 karma points
    Jan 31, 2011 @ 14:34
    Max Mumford
    0

    No node exists with id '0' error when setting up a node


    Server Error in '/' Application.

    No node exists with id '0'

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

    Exception Details: System.ArgumentException: No node exists with id '0'

    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: No node exists with id '0']
    umbraco.cms.businesslogic.CMSNode.setupNode() +397
    umbraco.cms.businesslogic.web.Document.setupNode() +90
    umbraco.cms.businesslogic.CMSNode..ctor(Int32 Id) +89
    umbraco.cms.businesslogic.Content..ctor(Int32 id) +44
    umbraco.cms.businesslogic.web.Document..ctor(Int32 id) +60
    umbraco.content.UpdateDocumentCache(Int32 pageId) +56
    umbraco.library.UpdateDocumentCache(Int32 DocumentId) +147
    umbracoDocumentApi.editContent.go_click(Object sender, EventArgs e) +632
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

    Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955

     

     

    I'm not entirely sure where in my code the error is happening. The code I am writing basically takes blog posts that have been imported by the CMSImport package and organises them into their respective blogpostdatefolder's. The only node creation that I do, is of the blog post date folders. Here is a section of the code for the creation of the year folders:

     

     

    bool yearExists = false;
    int yearExistsId = 0;
    Node createYearDateFolder;
    var checkForYearNode = umbraco.library.GetXmlNodeByXPath( blogPostParentFolder + "/descendant::node[contains(@nodeName, '" + year + "')]");

    if ( checkForYearNode.Count > 0 )
    {
    //Year node exists
    yearExists = true;
    yearExistsId = (*insert code for getting the node id from the checkforyearnode variable above*);
    }
    else {
    yearExists = false;
    }
    if (yearExists == false)
    {
    //create the document
    Document yearDateFolder = Document.MakeNew(year.ToString(), BlogDateFolderDocTypeId, author, blogPostParentFolder.Id);
    yearDateFolder.Publish(author);
    //assign it to the createYearDateFolder (needs to be of type NODE)
    createYearDateFolder = new Node(yearDateFolder.Id);
    umbraco.library.UpdateDocumentCache(createYearDateFolder.Id);
    }
    else
    {
    //declare createYearDateFolder variable
    createYearDateFolder = new Node(yearExistsId);
    }

     

    If anybody can help me track down the origin of this error and resolve it I will be very grateful :) Of course the final working code will be available free online.

    Thanks,
    Max.

Please Sign in or register to post replies

Write your reply to:

Draft