在控制器中:
ViewBag.Doors = new SelectList(new[]
{
new {ID = 1, Name="1-Door"},
new {ID = 2,Name="2-Doors"},
new {ID = 3,Name="3-Doors"},
new {ID = 4,Name="4-Doors"},
new {ID = 5,Name="5-Doors"},
new {ID = 6,Name="6-Doors"},
new {ID = 7,Name="7-Doors"}
},
"ID", "Name");
鉴于:
@Html.DropDownListFor(model => model.aboutcar.Doors, (SelectList)ViewBag.Doors, "--Select--")
当模型未经过验证并且应该再次重定向到此视图时,就会发生此错误。