DNN Forums

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

MVC Modules

Sort:
You are not authorized to post a reply.
Page 1 of 212 > >>





New Around Here





    Has anyone seen a real MVC based DNN module in the wild? I am building in-house custom modules and have done a simple MVC module which SMSs people a code to log them in, but I want to create one which has multiple module definitions and which will allow me to quickly and easily add new stuff without creating a million projects for each individual module.

     

    It really seems like because DNN doesn't support MVC routing (kind of important..) you can only build single view modules in MVC, which makes it practically useless. (MVC is a way of organizing a project, a one view / one action MVC is like a one form WinForms/WPF project which can only have an OnLoad and OnUpdate event..)

     

    Should I abandon this and learn ASP.NET WebForms to build stuff in DNN? I feel like if there just existed a non-trivial MVC project out there I could see how stuff is done, but customizing a .dnn manifest seems to break things and cause "Unknown error" things.






    New Around Here





      I really think if there was just some way of defining a set of modules within a package where each module points to a different controller that would be a nice way to organize an MVC project within DNN





      New Around Here





        One thing I am finding really frustrating is the lack of clear terminology. Modules, Desktop modules, module definitions, module controls, packages, these all seem to have subtly different but crucial meanings.

        e.g. I am finding that if I upload a [package]  with multiple [component type="Module"] inside it then I end up with a single entry in the Modules table but two entries in the DesktopModules table.

        (Edited  because anything in HTML tags seems to get filtered out)

        This doesn't work because in the DotNetNuke.Services.Installer.Installers.ModuleInstaller.cs ReadManifest() function it sets the FriendlyName for the DesktopModule to the FriendlyName of the Package; this means two DesktopModules are added with the same FriendlyName, and so when you go to add a module you get a "Key already exists" exception.

        Then if you go into the DesktopModule table and manually change the friendlyname to something different you have two desktop modules which share the same project, assemblies, folders, etc, allowing you to add two modules from the same project. I am currently trying to figure out what the heck DesktopModules are about to see if I am doing something crazy, but it appears to work well once I do this absurd hack.






        New Around Here





          Two things that were tripping me up:

          - Don't put multiple module definitions in the tab.. It will kind of work, but you get "Error occured when request service[sic] 'AddModule'" , which the error logs track down to a NullReferenceException in
          /API/internalservices/controlbar/AddModule
          Message:Object reference not set to an instance of an object.

          StackTrace:

          at DotNetNuke.Entities.Modules.ModuleController.IsSharedModule(ModuleInfo module) at DotNetNuke.Entities.Tabs.TabChangeTracker.TrackModuleModification(ModuleInfo module, Int32 moduleVersion, Int32 userId) at DotNetNuke.Entities.Modules.ModuleController.UpdateTabModuleOrder(Int32 tabId)

          Not sure why this happens, but it seems that if you add two or more definitions for component type="Module" in your .dnn manifest and then make sure you set the FriendlyName in DesktopModules to something different for each DesktopModule you can then finally have two or more modules in the Add modules pane which both reference the same assembly, same folder, same ModuleDefinition, but two DesktopModules.

          In an MVC project this means being able to address alternate controllers within the same project via different DesktopModule definitions.

          I am also finding the technique of having a "DefaultView" setting for the Module instance, which then redirects from Index() to Whatever() based on this setting, to be a nice way to configure different view for the same ModuleDefinition.


          Can anyone tell me if there is a DNN friendly way of altering the FriendlyName for a ModuleDefinition immidiately after installation, or if there is any reason not to use this approach?





          Growing Member





            Posted By Chris Kuliukas on 03 Jul 2019 11:13 PM

            It really seems like because DNN doesn't support MVC routing (kind of important..) you can only build single view modules in MVC, which makes it practically useless. (MVC is a way of organizing a project, a one view / one action MVC is like a one form WinForms/WPF project which can only have an OnLoad and OnUpdate event..)

            I can't help with your other questions, but have a read of Andrew Hoefling's DNN MVC Module Routing. My understanding is MVC Routing is supported now.

             






            New Around Here





              Thanks Olly, I did find it quite strange when I found that the routing seemed to be responding as I expected. Weird that in the documentation this limitation is made very prominent yet it no longer exists.





              Growing Member





                Assuming you mean the new documentation at DNNDocs.com, I beleive it's still a work in progress, with the community contributing as and when they have time. I'm sure PRs would be welcomed 😀






                New Around Here





                  Okay got it. Do you guys use Evoq by the way? It looks like we're definitely going to be using DNN for our intranet so I want to make sure we contribute back and support the company monetarily, and we have bought a few modules, but is purchasing Evoq the best way to do this and hopefully get some cooperation re: patch submissions?





                  New Around Here





                    e.g. I'm now running off a locally compiled 9.3.2 and would like to keep it that way so I can debug and use patches if absolutely necessary, but I would guess that with Evoq you don't get the source code?





                    New Around Here





                      Chris,
                      MVC in DNN is supported but there are little intricacies that trip people up because currently it does not have feature parity with ASP.NET MVC. The biggest thing that I recommend to people is take advantage of the GET/POST page life-cycle. This is because every page in DNN is wrapped inside of a form. If you want to handle advanced routing I have found it best to POST the page, process the logic and then redirect to your new route.
                      However, if you are just wanted to create navigation routes in an MVC module the same CSHTML methods you are familiar with in ASP.NET MVC should work such as
                      Url.Action() 
                      The best thing you can do is make sure you are running on the latest version of DNN. Big changes happened in DNN v9.2 and there continue to be improvements to the MVC platform as the versions iterate.
                      You are not authorized to post a reply.
                      Page 1 of 212 > >>

                      These Forums are dedicated to the 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. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
                      2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
                      3. 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.
                      4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
                      5. No Flaming or Trolling.
                      6. No Profanity, Racism, or Prejudice.
                      7. Site Moderators have the final word on approving / removing a thread or post or comment.
                      8. 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