我有这个:
@Html.Action("CheckForModifyPost", "Forums", new { postAuthor = item.Author.UserName, dateCreated = item.DateCreated})
我得到以下错误:
模型项传入 dictionary为null,但此字典需要非null模型项 类型为'System.Int32'。
item.Author.UserName
和item.DateCreated
都不为空,我所知道的是这与item.DateCreated
有关。我该如何解决这个错误?
答案 0 :(得分:0)
suppose your controller is as follow
ForumController.cs
[httpGet]
public void CheckForModifyPost(string postAuthor, DateTime dateCreated )
{
YOUR CODE GOES HERE
}
@Html.Action("CheckForModifyPost", "Forums", new { postAuthor = item.Author.UserName, dateCreated = item.DateCreated})
so in @html.Action pass the value with same name as in your action method like if in action method "postAuthor" as argument than in @html.Action pass the value of that argument with same name as in action method means use "postAuthor" in your @html.Action,
if their is only one character different than error occure