• Login
  • Register

DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Replace Deprecated in Platform 9.4.2

You are not authorized to post a reply.
Sort:


New Member


Posts:5
New Member

    Dealing with replacement of two depcrecated methods somewhat releated in our code.

    This first one, I see has its own threads, so I will avoid it.

    'Public Overloads Function NavigateURL() As String' is obsolete: 'Deprecated in Platform 9.4.2.

    The one I am interested in is commonly used as a paramter to the first:

    'Function GetCurrentPortalSettings() As PortalSettings' is obsolete: 'Deprecated in Platform 9.4.2.

    I replaced 

    Dim PortalSettings As Entities.Portals.PortalSettings = Entities.Portals.PortalController.Instance.GetCurrentPortalSettings

    With the new interface version

    Dim PortalSettings = Entities.Portals.PortalController.Instance.GetCurrentSettings.

    But this property that was available before is no longer.- PortalSettings.ActiveTab.TabID

     Where can I find missing properties?

     



    Basic Member


    Posts:99
    Basic Member

      DNN partner specializing in custom, enterprise DNN development https://engagesoftware.com/showcase


      New Member


      Posts:5
      New Member

        Thanks, now to get back to the seemingly more difficult one. NavigateURL() As String' is obsolete: 'Deprecated in Platform 9.4.2.

        Did not see a way to mark this as Solved, maybe we dont have that feature.


        Veteran Member


        Posts:1051
        Veteran Member

          Some discussion of this can be found at https://dnncommunity.org/forums/aft/794/afpg/2

          Here is an excerpt that (I hope) contains the replacement process. The entire thread is worth reading. And, it would be nice if something about this got added to dnndocs.com. I'll leave that to someone else ...

          26 Jul 2020 08:42 PM

          Here is a full synopsis of how to move from the old NavigateURL to the new method

          References for your project must be made to:

          DotNetNuke.Abstractions
          Microsoft.Extensions.DependencyInjection
          Microsoft.Extensions.DependencyInjection.Abstractions
          * the dlls can be found in the bin directory

          DotNetNuke.Abstractions is required for INavigationManager and must be declared above as an imports or using (depending on language) before your class definition

          Microsoft.Extensions.DependencyInjection is required as an imports/using so that you can call on the PortalModuleBase.DependencyProvider


          Each of these returns a string which you can then do redirects with or whatever.

          The old way - Common.Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "YourControlKey", "mid=" & CStr(ModuleId))

          The new way - DependencyProvider.GetRequiredService(Of INavigationManager).NavigateURL(PortalSettings.ActiveTab.TabID, "YourControlKey", "mid=" & CStr(ModuleId))

          If you want to circumvent the call to DotNetNuke.Abstractions you can call it like this:

          DependencyProvider.GetRequiredService(Of Abstractions.INavigationManager).NavigateURL(PortalSettings.ActiveTab.TabID, "YourControlKey", "mid=" & CStr(ModuleId))
          Joe Craig
          DNN MVP
          Patapsco Research Group


          Basic Member


          Posts:99
          Basic Member

            Mac, you'll need to use the INavigationManager.NavigateURL method instead. How you obtain an INavigationManager instance varies based on your development paradigm.

            At a high level, the answer is that you'll request one from the dependency injection container. If you're using MVC controllers or Web API controllers, you can just add a parameter to your controller's constructor and the framework will supply that dependency automatically. Here's a Web API controller example:

            Imports DotNetNuke.DependencyInjection
            Imports Microsoft.Extensions.DependencyInjection
            
            Public Class MyController
                Inherits DnnApiController
            
                Private ReadOnly navigationManager As INavigationManager
            
                Public Sub New(ByVal navigationManager As INavigationManager)
                    Me.navigationManager = navigationManager
                End Sub
            End Class

            You can see a fuller discussion with more examples at https://dnncommunity.org/forums/aft/2002#5875. Hope it helps!

            DNN partner specializing in custom, enterprise DNN development https://engagesoftware.com/showcase


            New Member


            Posts:5
            New Member

              Very good info guys, thanks.
              I had read through the thread referenced and it seemed to be a very complex solution. I think that because our design is using web forms rather than mvc, maybe it simplified my fix. I almost dont trust it yet . I had found the reply that Joe mentioned and used it to make this modification and it worked. I will have to add the references and imports to multiple modules where we were using the NavigateURL. If there is a flaw that you can see here, please let me know.
              Private Sub lbtnGoHome_Click(sender As Object, e As EventArgs) Handles lbtnGoHome.Click
                      Dim lcPortalController As New DotNetNuke.Entities.Portals.PortalController
                       Dim lcPortalInfo As New DotNetNuke.Entities.Portals.PortalInfo
                       lcPortalInfo = lcPortalController.GetPortal(Me.PortalId)

                        Response.Redirect(DependencyProvider.GetRequiredService(Of                         Abstractions.INavigationManager).NavigateURL(lcPortalInfo.HomeTabId), False)
                        ' replaced .... Response.Redirect(DotNetNuke.Common.NavigateURL(lcPortalInfo.HomeTabId, False))
               

              You are not authorized to post a reply.

              These Forums are dedicated to discussion of DNN Platform.

              For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

              1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
              2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
              3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
              4. No Flaming or Trolling.
              5. No Profanity, Racism, or Prejudice.
              6. Site Moderators have the final word on approving / removing a thread or post or comment.
              7. English language posting only, please.

              Would you like to help us?

              Awesome! Simply post in the forums using the link below and we'll get you started.

              Get Involved