DNN Forums

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

Site information from an outside console application

Sort:
You are not authorized to post a reply.





New Around Here





    Hi all,

    I have a site running with DNN, and now I want to add a windows service task to execute some synchronization actions frequently.

    To try it, I have created my console application with my connection string and I try to use, for example, to get the module settings of a particular module inside my site:

     ModuleController moduleController = new ModuleController();
            ArrayList modules = moduleController.GetModulesByDefinition(portalId, moduleName); 

    However I always got NullReference excepton inside.

    I guess that the dataprovider is not loaded in my console application (I have previously solved all dependency reference). 

    Is this possible? There is some method to instantiate the portal information to be able to access to my modules information?

    Many thanks in advance.






    Growing Member





      No. This is not possible.

      You need to create a Web API on your site and consume it in your Console app.

      If you have direct access to the database then you should query the database directly. DNN API will not work in a Console App since it has a dependency on ASP.NET and requires that it's used in context of a web application.
      Sincerely,
      Mandeep Singh

      CEO & Founder | Mandeeps.com
      CEO & Founder | Vanjaro





      New Around Here





        Many thanks for your quick response.

        I am investigating a task schedule that seems will be able to work for the purpose I am looking for.

        You are not authorized to post a reply.

        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