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.
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.
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:
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.
is working on a reply...