本文介绍了错误:传递到字典的模型项的类型为"ContactWeb.Models.RoleListViewModel",但是字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下代码行上遇到麻烦:@{Html.RenderPartial("Form", Model.Contact);}这是我得到的错误:传递到词典中的模型项的类型为"ContactWeb.Models.RoleListViewModel",但是此词典需要模型类型为"ContactWebLibrary.Contact"的模型项.

I'm having trouble with this line of code: @{Html.RenderPartial("Form", Model.Contact);}This is the error I'm getting:The model item passed into the dictionary is of type 'ContactWeb.Models.RoleListViewModel', but this dictionary requires a model item of type 'ContactWebLibrary.Contact'.

我在视图顶部列出了RoleListViewModel,并且在RoleListViewModel中具有Contact属性,所以我不确定为什么会抱怨.谁能帮我解决这个问题?谢谢.

I have RoleListViewModel listed at the top of the view and I have Contact property in my RoleListViewModel so I'm not sure why it's complaining. Can anyone please help me to fix this problem? Thanks.

推荐答案

作为第三个参数,您需要传入新的ViewDataDictionary.

As a third parameter, you need to pass in a new ViewDataDictionary.

这篇关于错误:传递到字典的模型项的类型为"ContactWeb.Models.RoleListViewModel",但是字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 23:11