ActionResult参数为空

时间:2018-04-18 09:12:10

标签: c# asp.net asp.net-mvc asp.net-mvc-4

我有一个视图,通过单击按钮,应该同步模型列表中的数据。 ActionLink包含以下代码:

@Html.ActionLink("Accept Change", "AcceptChange", "Question", new { index = i, draftAnswers = Model.DraftAnswers, finalAnswers = Model.FinalAnswers }, new { @class = "acceptButton" })

该模型具有以下结构:

[NotMapped]
[Serializable]
public class SurveyFill
{
    public List<Question> FinalAnswers { get; set; }
    public List<Question> DraftAnswers { get; set; }
    public Country Country { get; set; }
}

ActionResult上的 AcceptChange QuestionController

 public ActionResult AcceptChange(int index, List<Question> draftAnswers, List<Question> finalAnswers)
    {
        int country = finalAnswers.FirstOrDefault() != null ? finalAnswers.FirstOrDefault().Country.ID : 0;

        if (country != 0)
        {
            finalAnswers[ind].SyncProperties(draftAnswers[ind]);

            SurveyFill survey = new SurveyFill();
            survey.Country = this.Database.Countries.Where(c => c.ID == country).SingleOrDefault();
            survey.FinalAnswers = finalAnswers;
            survey.DraftAnswers = draftAnswers;
            return View(survey);
        }
        return RedirectToAction("Index");
    }

问题是模型中的列表不会发送到AcceptChange。任何人都知道瓶颈在哪里?我试着在论坛上阅读一些帖子,但是找不到错误。

0 个答案:

没有答案