I have a layout which it has two partial views, one for LogIn and one for Register.
//Login (In layout)
@Html.Partial("_LoginPartial")
and in the partial
@model LogOnVM
///register (in layout)
@Html.Partial("_RegisterPartial")
and in the partial
@model RegisterVM
As it shown, both of them have different Models.
My problem is that when I am trying to add one more view(with different model) that is derived from this layout I am getting the following error
The model item passed into the
dictionary is of type ‘HomeVM’, but
this dictionary requires a model item
of type ‘LogOnVM’.
How could I render the partials in the layout without having any problem with the other views?
Thanks
Well, I found a solution.
Instead of calling the partials with
RenderPartial, I have created twoActionResultmethods inAccountController:LoginPartial)RegisterPartial).Then in layout I call them with
RenderAction():I don’t know if it is the best approach for performance but it works fine.