我有一个带有2个选择框的表单。但是当我单击“提交”按钮时,会出现“无法创建抽象类”的错误。我不知道这里出了什么问题
@using (Html.BeginForm("Add", "Admin")) {
<input type="submit" value="Add" class="btn btn-warning small-text custom-btn" />
<div class="select-box">
<select name="users[]" multiple size="35">@{ Html.RenderAction("UserList", "GroupsAndUsers"); }</select>
</div>
<div class="select-box">
<p class="blue-text bold-text">Groups</p>
<select name="group" size="35">@{ Html.RenderAction("GroupList", "GroupsAndUsers"); }</select>
</div>
<input type="hidden" name="RedirectToUrl" value="~/GroupsAndUsers/AddUsers" />
}
管理/添加
[HttpPost]
public ActionResult Add(Array userIDs, int groupID, string RedirectToUrl)
{
return Redirect(RedirectToUrl);
}
答案 0 :(得分:2)
Array
is an abstract class,因此MVC不知道在绑定参数时要创建哪个特定的Array实现。尝试类似:
public ActionResult Add(int[] userIDs, int groupID, string RedirectToUrl)