Try our conversational search powered by Generative AI!

Admin Plugin return 404



I've searched far and wide across the web for a solution, but being completely new to Episerver and the world of CMS, I just can't seem to get it right.
I manage to get my plugin to show up in the admin tools menu, and up until yesterday it actually crashed visually for me. Now I didn't get anything until I actually opened the console and it seems to return "the server responded with a status of 404 ()". Any ideas how to fix this?

Here's my controller that I try to get to fire:

        Area = PlugInArea.AdminMenu,
        Url = "~/modules/SecurityTxtHandler/SecurityTxtAdmin",
        DisplayName = "Manage security.txt content",
        Description = "Tool to edit security.txt")]

    [Authorize(Roles = "CmsAdmins")]
    public class SecurityTxtAdminController : Controller
        protected ISecurityContentService SecurityService { get; set; }
        public SecurityTxtAdminController()
            SecurityService = new SecurityContentService();
        public ActionResult Index()
            var model = new SecurityTxtViewModel();

            var listAllHosts = GetAllHosts();
            model.SiteList = listAllHosts;

            if (listAllHosts.Count > 0)
                model.SecurityContent = SecurityService.GetSecurityContent(listAllHosts.First().Value);

            return View(model);

And my initialization:

    public class CustomRouteInitialization : IInitializableModule
        public void Initialize(InitializationEngine context)
            RouteTable.Routes.MapRoute("SecurityTxtRoute", "security.txt", new { controller = "SecurityTxt", action = "Index" });

        public void Uninitialize(InitializationEngine context)
        public void Preload(string[] parameters)
Oct 13, 2021 11:34

From memory I think the value you pass on the second param of the MapRoutes need to match the Url in your GuiPlugin declaration.

For example you see in this post both the URL and the Route param match. Also the URL isn't a path to a file it's just a unique path to identify your module. So I would change both values to "custom-plugins/securitytxt"

Edited, Oct 13, 2021 12:05

One other point, this way of creating plugins has been removed for the .NET 5 version (CMS 12) so if you have any expectation of upgrading in the future I'd create it using a menu item in the editor as show here which works for now and for CMS 12 (.NET 5)

Edited, Oct 13, 2021 12:08
Mark Stott - Oct 13, 2021 15:03
Thank you for the blog reference Scott :)
Scott Reed - Oct 13, 2021 15:04
Haha no worries, I've shared it a few times :p

Thanks for the help Scott, I managed to get the URL right in the end, now it's pointing to the right controller and action. Evidently the blog post (which I have read a few times) was a big help, and there's a small "/" at one of the url-pointers that I missed. Working fine now! 

Oct 14, 2021 13:39
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.