Url to views for custom reports and admin plugins



I am working on a hobby project that will add an admin plugin and a couple of cms reports. I plan to package it as a nuget package for others to use. Currently I am stuck on how to set the url for the view files (Razor) and where to place them in the project.

I have been looking at a couple projects on GitHub and I currently have this (simplified) file structure:


My controller looks like this:

        Area = PlugInArea.AdminConfigMenu,
        UrlFromModuleFolder = "Views/MyPlugin/Index",
        DisplayName = "This is my plugin"
    public class MyPluginController : Controller
        public ActionResult Index()
            return View();

To test my code I have set up the AlloyMvc site as a second project in the solution and set Alloy to depend on my project. My plugin is detected and shows up in the admin interface but the view is not found. (error message reports searched physical path as {pathToSolution}\{theAlloyMvcProjectName}\EPiServer\CMS\Admin\MyPlugin\Index)

The EPiServer documentation on custom reports specifies a url in a hardcoded way and adds a route in the global.asax file but that is not an option.

I hope for a solution that makes it easy to test while coding and that also will work when package as a nuget and installed by someone else. What do I need to configure and where?

Sep 15, 2019 18:02


You should not use path to your view as "location" of the module. View is just a template that will be used by Razor ViewEngine to render the result. "Somebody" has to execute request - that's Mvc Controller. Instead - try to point to your controller:

[..., UrlFromModuleFolder = "MyPlugin", ...]

Sep 15, 2019 21:20

I never tried making modules before. I tried changing the UrlFromModuleFolder as you showed but the same error message still appears but with a slightly changed path.

I have not specified any module location and only the assembly name in config files, and I do not find any location config settings in the projects I have been looking in for help either. I do not understand what you are saying I should change.

There are probably some more things I need to configure aswell. Currently to be able to run and debug my code at all I have added the bin file of the project's assembly as a dependency to the AlloyMvc project... (Its working, a Scheduled job that is a part of the module runs without any problems on Alloy)

I have uploaded my code to GitHub if anyone wants to take a look and come with suggestions on what may be wrong.

Sep 16, 2019 19:32

look for PR..

Sep 17, 2019 21:01

I have been trying some more things including the changes in valdis pull request.

After much struggle I have found a solution that requires me to build a nuget package and reinstall it everytime I want to test even the smallest changes in my dev environment. However, it is working!

Sep 22, 2019 12:31

what are the changes?

Sep 23, 2019 0:34

The biggest change was that I had to start building the project to a nuget and install it for the views to work, I had hoped to avoid the nuget step in my dev environment. Other things that I tried may also have been required, the code on GitHub is updated.

Here is my nuspec file and I build the package from inside the nuget-directory with the following command that gives me a package I can install in my test project:

nuget.exe pack ..\MoreCmsReports.csproj.nuspec

The routes section in module.config is not required, the UrlFromModuleFolder needs to match the controller name (excluding controller suffix).

Sep 23, 2019 8:18

one trick might be to skip nuget step - to zip it up and the xcopy to sandbox project /modules/... folder. give it a try

Sep 23, 2019 9:28
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.