Search code examples
asp.net-mvcdotnetnukedotnetnuke-module

MVC alternative for PortalModuleBase.ControlPath?


How can I access the ControlPath property for a module inside one of its views? In a webforms module, the user control inherited from PortalModuleBase which provided the ControlPath. What is the MVC equivalent?


Solution

  • Apeksha,

    Sorry this is so late, but here is what I worked up...

    In your MVC controller action:

    ViewBag.ModulePath = $"~/DesktopModules/MVC/{ModuleContext.Configuration.DesktopModule.FolderName}";
    

    Then in your razor view:

    @{
        ClientResourceManager.RegisterStyleSheet(Dnn.DnnPage, ViewBag.ModulePath + "/Resources/bootstrap/css/bootstrap.min.css");
    }
    

    If you need the server path, just add:

    Server.MapPath(ViewBag.ModulePath);