4

I want to handle PageModel using custom Controller/Action in DXA module.

I added controller:

public class CustomPageController : PageController
{
    public override ActionResult Page(string pageUrl)
    {
        return base.Page(pageUrl);
    }
}

and registered page model view:

RegisterViewModel("AssetPage", typeof(PageModel), "CustomPage");

but when I'm triyng to reach the page I get the error: No View Model registered for View 'MyWeb:Page:AssetPage'. Check that you have registered this View in the 'MyWeb' area registration.

4

The Page Controller is resolved through MVC Routing rather than through DXA View Model Registration.

In order to use a custom Page Controller, you should change the "Tridion Page Route" in RegisterRoutes in Global.asax.cs. https://github.com/sdl/dxa-web-application-dotnet/blob/master/Site/Global.asax.cs

Don't specify the third parameter in RegisterViewModel (that is intended for custom Entity Controllers).

  • HI @Rick, We have tried adding custom controller by extending PageController of Sdl.Web.Mvc project, also added new { controller = "MyPage", action = "Page" } under "Tridion Route Page", also override method Page under MyController, but debug point is not triggering on MyPageController, Please advise on this what should be the problem? – Neetesh Narvaria Sep 4 '18 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.