I need to call this very usefull function of DNN from my Scheduler Class but I always get the following error.
Object reference not set to an instance of an object., stack at DotNetNuke.Common.Globals.NavigateURL(Int32 TabID, Boolean IsSuperTab, PortalSettings settings, String ControlKey, String Language, String[] AdditionalParameters) at DotNetNuke.Common.Globals.NavigateURL(Int32 TabID, Boolean IsSuperTab, PortalSettings settings, String ControlKey, String[] AdditionalParameters) at DotNetNuke.Common.Globals.NavigateURL(Int32 TabID, PortalSettings settings, String ControlKey, String[].....
For now I have no idea whats happening, I have already post an entry in this very old thread in DotNetNuke Forum and hopefully somebody can share there solution.
I will keep digging on this one, Once I have a solution I will add a comment on this post.
a s t a l a v i s t a
Upon viewing the source code for NavigateURL function I notice that it gets the PortalSettings using PortalController.GetCurrentPortalSettings function which gets its data from HttpContext.Current.Items("PortalSettings") which we dont have if we are inside a Scheduled Task.
ReplyDeleteSo the solution is to include your portalsettings when calling the function. see below:
This will return an error:
DotNetNuke.Common.Globals.NavigateURL(_lastTabId, "", "view=detail", "messageid=" & messageId.ToString)
This one will work
DotNetNuke.Common.Globals.NavigateURL(_lastTabId, _portalSettings, "", "view=detail", "messageid=" & messageId.ToString)
Now its up to you how you get your portalsettings.
Thanks
ReplyDeleteTo get your portalsettings use this:
new DotNetNuke.Entities.Portals.PortalSettings(portalID)