Error when trying to inject 2sxc app into DNN template

82 Views Asked by At

I'm trying to inject a 2sxc app into a DNN template file - as per this great tutorial from WolfXMachina

Tutorial code:

<%@ Import Namespace="DotNetNuke.Entities.Modules" %>
<%@ Import Namespace="ToSic.Sxc.Dnn" %>
<%@ Import Namespace="ToSic.Sxc.Services" %>
 <%
    var moduleController = new ModuleController();
    ModuleInfo footerModule = moduleController.GetModule(39, 394);
    if (footerModule != null) {
  %>
    <%= this.GetScopedService<IRenderService>().Module(39, 394) %>
  <%
    }
  %>

I checked for the page id and grabbed the ID for the app from the 2sxc app list. enter image description here

But I'm getting the following error (Object reference not set to an instance of an object):

    DotNetNuke.Services.Exceptions.Exceptions - DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at ToSic.Sxc.Dnn.DnnModuleAndBlockBuilder.GetModuleImplementation(Int32 pageId, Int32 moduleId) in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn.Core\Dnn\DnnModuleAndBlockBuilder.cs:line 30
   at ToSic.Sxc.Blocks.ModuleAndBlockBuilder.GetBlock(Int32 pageId, Int32 moduleId) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Blocks\ModuleAndBlockBuilder.cs:line 25
   at ToSic.Sxc.Blocks.RenderService.Module(Int32 pageId, Int32 moduleId) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Blocks\Renderers\RenderService.cs:line 124
   at ToSic.Sxc.Dnn.Services.DnnRenderService.Module(Int32 pageId, Int32 moduleId) in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn.Core\Dnn\Services\DnnRenderService.cs:line 37

What I'm I doing wrong or is there another location where I can get the app ID?

1

There are 1 best solutions below

4
iJungleBoy On

I'm a bit confused about you mentioning the AppId. It also doesn't appear in your code above, and you don't need it.

Basically you would add a module to any page - usually hidden.

Then you would use the ID of that page and module for this.