Use Content Tree based routing, but use page types from separate project/DLL in Kentico 13

Michael Webb asked on January 12, 2023 21:44

I have a Kentico 13 site that my team is currently working on. One issue we are running into is that if all the Page Type generated code is in the MVC project/DLL then Content Tree based routing works fine, but if we move the generated code into a separate shared project/DLL, the type does not seem to be recognized for routing.

Here is the error being generated when navigating to the tree node with this routing enabled:

InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'Kentico.Content.Web.Mvc.Routing.PageViewModel1[CMS.DocumentEngine.TreeNode]', but this ViewDataDictionary instance requires a model item of type 'Kentico.Content.Web.Mvc.Routing.IPageViewModel1[CMS.DocumentEngine.Types.MyProject.MyNode]'.

To reiterate, if I move the generated code from the separate shared project/DLL back into the MVC project this error goes away.

Is there something else I need to do to have Kentico recognize page type generated class code from other DLLs?

Correct Answer

Jeroen Fürst answered on January 13, 2023 08:58

Hi Michael,

Did you enable class discovery in the separate shared project?

Cheers, Jeroen

1 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.