Server Error in '/' Application.

Current node is null. This might be due to previewing an unpublished node. As the NodeFactory works with published data, macros using the node factory won't work in preview mode.
Parameter name: Current node is 1506

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: Current node is null. This might be due to previewing an unpublished node. As the NodeFactory works with published data, macros using the node factory won't work in preview mode.
Parameter name: Current node is 1506

Source Error:


Line 17:         {
Line 18:             // Create Document type object
Line 19:             Node currentNode = Node.GetCurrent();
Line 20:             int currNodeID = currentNode.Id;
Line 21: 

Source File: d:\web\localuser\wcf3k.dk\public_html\usercontrols\results.ascx.cs    Line: 19

Stack Trace:


[ArgumentException: Current node is null. This might be due to previewing an unpublished node. As the NodeFactory works with published data, macros using the node factory won't work in preview mode.
Parameter name: Current node is 1506]
   umbraco.NodeFactory.Node.getCurrentNodeId() +297
   umbraco.NodeFactory.Node.GetCurrent() +9
   usercontrols_exceltest.Page_Load(Object sender, EventArgs e) in d:\web\localuser\wcf3k.dk\public_html\usercontrols\results.ascx.cs:19
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
   System.Web.UI.Control.OnLoad(EventArgs e) +97
   System.Web.UI.Control.LoadRecursive() +61
   System.Web.UI.Control.LoadRecursive() +134
   System.Web.UI.Control.LoadRecursive() +134
   System.Web.UI.Control.LoadRecursive() +134
   System.Web.UI.Control.LoadRecursive() +134
   System.Web.UI.Control.LoadRecursive() +134
   System.Web.UI.Control.LoadRecursive() +134
   System.Web.UI.Control.LoadRecursive() +134
   System.Web.UI.Control.LoadRecursive() +134
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4700.0