I am trying to add reference of my model in the _layout or component view but for latter it's saying two models are not allowed since there is already -

@model IComponent

And when I try to add a model(@model Test.Navigation) on top of my _layout view the error is -

"The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[MyWebSite.ViewModels.Navigation]', but this dictionary requires a model item of type 'DD4T.ContentModel.IPage'."

Please confirm if models other than the IComponent or IPage are allowed? If so, how I can achieve it?

2 Answers 2


You can use any class as a model in DD4T. Generally in MVC Layout files don't usually have a model. If I was you I would create an Action method called Render in a controller called NavigationController and then call that using Html.Action() in your Layout file.

Your View for this Action can then be the model you want and your logic for rendering the navigation information can be encapsulated in a single method.

  • How can I pass model in Action, it only allows the following as paramenter- this HtmlHelper htmlHelper, string actionName, string controllerName, Object routeValues
    – user945
    Commented Apr 3, 2014 at 15:18
  • You should retreive the information for your model and create an instance of your model in the action method rather than trying to pass the model from the view to the action. Think about Model View Controller principles. Commented Apr 3, 2014 at 15:28

As far as I know DD4T supports IComponent/IPage as models for the view.

But you can use ViewData or ViewBag (works only for MVC 4 since it's dependent on C# 4.0) classes to pass additional information to the View.

ViewData is a dictionary of key/value pairs and ViewBag uses C# 4.0 features to have dynamic properties that can be accessed in the view.

Read more here.

Hope this helps resolve your query.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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