but this ViewDataDictionary instance requires a model item of type XX

錯誤內容:The model item passed into the ViewDataDictionary is of Type XXX but this ViewDataDictionary instance requires a model item of Type XXX


發生原因:

1.在Laoyout.cshtml 裡面想要傳入@model,但傳不進去。

解法:

把 _Layout.cshtml 裡面的 @model yourmodel 給拿掉就好了