+1-888-365-2779
Try Now
More in this section

Forums / 3.x Pre-release forums (retired) / Creating New Page Error.

Creating New Page Error.

5 posts, 0 answered
  1. Sean
    Sean avatar
    271 posts
    Registered:
    31 May 2006
    23 Nov 2006
    Link to this post
    Hi,

    I am getting this error after trying to create any new page:

     

    Server Error in '/XXXX' Application.

    Object reference not set to an instance of an object.

    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.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

    1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

      <%@ Page Language="C#" Debug="true" %>

    or:

    2) Add the following section to the configuration file of your application:

    <configuration>
       <system.web>
           <compilation debug="true"/>
       </system.web>
    </configuration>

    Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

    Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       ASP.global_asax.HideRootNode(Object sender, SiteMapResolveEventArgs e) +10
       System.Web.SiteMapProvider.ResolveSiteMapNode(HttpContext context) +335
       System.Web.SiteMapProvider.get_CurrentNode() +19
       System.Web.SiteMapProvider.GetCurrentNodeAndHintAncestorNodes(Int32 upLevel) +14
       System.Web.UI.WebControls.SiteMapPath.CreateControlHierarchy() +53
       System.Web.UI.WebControls.SiteMapPath.CreateChildControls() +29
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.WebControls.CompositeControl.get_Controls() +12
       Telerik.Cms.Web.CmsHelper.FindContentPlaceHolders(Control control, List`1 list) +99
       Telerik.Cms.Web.CmsHelper.FindContentPlaceHolders(Control control, List`1 list) +160
       Telerik.Cms.Web.CmsHelper.FindContentPlaceHolders(Control control, List`1 list) +160
       Telerik.Cms.Web.UI.Toolbox.LoadZones() +226
       Telerik.Cms.Web.UI.Toolbox.CreateChildControls() +1524
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.WebControls.CompositeControl.get_Controls() +12
       Telerik.Cms.Web.CmsHelper.FindContentPlaceHolders(Control control, List`1 list) +99
       Telerik.Cms.Web.CmsHelper.FindContentPlaceHolders(Control control, List`1 list) +160
       Telerik.Cms.Web.CmsHelper.FindContentPlaceHolders(Control control, List`1 list) +160
       Telerik.Cms.Web.CmsHelper.FindContentPlaceHolders(Control control, List`1 list) +160
       Telerik.Cms.Web.EditPage.LoadCmsControls() +115
       Telerik.Cms.Web.EditPage.CreateChildControls() +631
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.Control.PreRenderRecursiveInternal() +41
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

    I upgraded my website as you specified between 2 beta versions, these are the steps I took:
    1. Upgraded the website by copying all the files including the web.config
    2. Updated the connection to point to the old database.
    3. Logged in.
    4. Went to the pages admin
    5. Deleted all the pages except home
    6. Created a new page.
    7. Error comes up

    I tried it with a fresh database and it does the same thing, so I guess it isn't because of the upgrade.  The only custom changes I have made so far was to add a couple of themes...

    Cheers
    Sean

  2. Bob
    Bob avatar
    330 posts
    Registered:
    24 Sep 2012
    23 Nov 2006
    Link to this post
    Hi Sean,

    I see you have added global.asax file. Could you please send it to me? I will try to reproduce the problem here.

    Meanwhile please remove the reference to HideRootNode handler, this should solve the problem.


    All the best,
    Bob
    the telerik team
  3. Sean
    Sean avatar
    271 posts
    Registered:
    31 May 2006
    23 Nov 2006
    Link to this post
    Hi Bob,

    Sorry I didn't even notice that, I just assumed it was something else.  I had forgotten I have even put that in there, I will tell you what I was trying to do.  I was trying to add a SiteMapPath control to a template so that I could just use the Sitemap datasource of course it then renders the [Site Map] Root Node that is part of Sitefinity, so I thought I was being clever overriding it, to hide the root node...  It seemed to work with the previous beta, I think, anyway.  I thought I would send you this code out of interest.  I should probably build my own SiteMapPath control, I just thought I would save time by using the built in one.

    In case you are interested here is the relevant code, I was using in the global asax.

    void Application_Start(object sender, EventArgs e)

    {

    // Code that runs on application startup

    SiteMap.SiteMapResolve += new SiteMapResolveEventHandler(HideRootNode);

    }

    static SiteMapNode HideRootNode(Object sender, SiteMapResolveEventArgs e)

    {

    //

    // Hide the root node from SiteMapPath controls by cloning the site

    // map from the current node up to the node below the root node and

    // setting that node's ParentNode property to null.

    //

    SiteMapNode node = SiteMap.CurrentNode.Clone();

    SiteMapNode current = node;

    SiteMapNode root = SiteMap.RootNode;

    if (current != root) // Just in case the current node *is* the root node!

    {

    while (node.ParentNode != root)

    {

    node.ParentNode = node.ParentNode.Clone();

    node = node.ParentNode;

    }

    node.ParentNode.Title = "Home";

    node.ParentNode.Url="~/";

    }

    return current;

    }

    Thanks for point out something I really should have noticed myself...
  4. Sean
    Sean avatar
    271 posts
    Registered:
    31 May 2006
    23 Nov 2006
    Link to this post
    Hi,

    I solved the problem in the mean time.... can you think of any other problems using this code might cause with your system?

    static SiteMapNode HideRootNode(Object sender, SiteMapResolveEventArgs e)

    {

    //

    // Hide the root node from SiteMapPath controls by cloning the site

    // map from the current node up to the node below the root node and

    // setting that node's ParentNode property to null.

    //

    if (SiteMap.CurrentNode != null)

    {

    SiteMapNode node = SiteMap.CurrentNode.Clone();

     

    SiteMapNode current = node;

    SiteMapNode root = SiteMap.RootNode;

     

    if (current != root) // Just in case the current node *is* the root node!

    {

    while (node.ParentNode != root)

    {

    node.ParentNode = node.ParentNode.Clone();

    node = node.ParentNode;

    }

    node.ParentNode.Title = "Home";

    node.ParentNode.Url = "~/";

    }

    return current;

    }else{

    return SiteMap.CurrentNode;

    }

    }

    Thanks

    Sean

  5. Bob
    Bob avatar
    330 posts
    Registered:
    24 Sep 2012
    23 Nov 2006
    Link to this post
    Hi Sean,

    The provided code looks good and it should work fine. There is a problem with SiteMapPath control though if the application is not the root of the web site. It doesn’t resolve the application root for some reason. I will investigate this as soon as I get some time.

    Kind regards,
    Bob
    the telerik team
Register for webinar
5 posts, 0 answered