Thursday, April 8, 2010

DotNetNuke.Common.Globals.NavigateURL() Inside DotNetNuke Scheduler

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

2 comments:

  1. 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.

    So 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.

    ReplyDelete
  2. Thanks

    To get your portalsettings use this:
    new DotNetNuke.Entities.Portals.PortalSettings(portalID)

    ReplyDelete