Try our conversational search powered by Generative AI!

PageController with multiple Views - inline editable?


When a single PageController has multiple methods that return different Views, these views does not seem previewable in preview mode in the CMS system, when clicking an actionlink to the view in edit mode I am returned to the Index page. The content is not inline editable.

So e.g. if I have a class:

class EntityController : PageController {

  ActionMethod Index(){... return View("~/Views/Entity/Index.cshtml")}

  ActionMethod Edit(Guid id){... return View("~/Views/Entity/Edit.cshtml")}

  ActionMethod Create(){... return View("~/Views/Entity/Create.cshtml")}


And in the Index.cshtml view:

@Html.ActionLink("Edit", "Edit", new { id = row.Id })

This works fine in the non edit mode, but clicking the button in edit mode does not load the Edit page but returns to the index page and the content is not inline editable.

How do you deal with this? Do I really hav to make PageTypes and PageControllers for each view?

Edited, May 02, 2018 14:42

My guess is you have to manually add custom page edit routes to RouteCollection. The default page edit route looks like this:

    RouteCollectionExtensions.CmsHomePath + "{language}/{nodeedit}/{partial}/{action}", 
        action = "index"

RouteCollectionExtensions.CmsHomePath is unfortunately private and contains this:

private static string CmsHomePath
    return VirtualPathResolver.Instance.ToAppRelative(VirtualPathUtility.AppendTrailingSlash(ModuleResourceResolver.Instance.ResolvePath("CMS", "Content"))).Substring(1);
May 02, 2018 16:27

Yes you need a PageType or BlockType for it to be manageble in the CMS. 

May 02, 2018 19:57

Thanks for the responses. Maybe I can reuse the same controller class for multiple Page/Blocktypes?

May 03, 2018 8:28

theoretically you can if contnet types are "compatible". look for TemplateDescriptors keyword in documentation.

May 03, 2018 12:13

Thanks. I ended up just creating a page for each controller. With a baseclass for shared properties.

May 08, 2018 6:52
* 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.