Asp.net mvc 在MVC中获取Html.ListBoxFor post上的数据

Asp.net mvc 在MVC中获取Html.ListBoxFor post上的数据,asp.net-mvc,html-helper,html.listboxfor,Asp.net Mvc,Html Helper,Html.listboxfor,似乎我能找到的所有示例都出于某种原因使用了ViewModel,所以我想要的答案是MVC而不是MVVM:) 控制器 List<PermOptions> have = new List<PermOptions>(); List<PermOptions> nothave = new List<PermOptions>(); ...populate the lists here... var set = new PermissionSet

似乎我能找到的所有示例都出于某种原因使用了ViewModel,所以我想要的答案是MVC而不是MVVM:)

控制器

List<PermOptions> have = new List<PermOptions>();
List<PermOptions> nothave = new List<PermOptions>();

...populate the lists here...

var set = new PermissionSet
        {
            ExtId = extid,
            HaveList = have,
            NotHaveList = nothave
        };

return View(set);
显示初始列表和移动项目时一切正常,但当我提交表单时,ListBoxFors是Post操作的一部分,PermissionSet.HaveList和PermissionSet.NotHaveList为空,计数为零。认为这是一个选择问题或返回问题的格式,我添加了javascript来选择两个框中的所有项目,在浏览器调试窗格中,我可以看到提交的表单数据中有一些值与NotHave和Have的各种选项值相匹配,但如果在Post操作中,我调用ViewData[“NotHave”],它也报告为空

我需要做什么才能在我的Post controller中获取每个ListBoxFor中的项目列表,最好是作为PermissionSet的一部分

@model path.to.model.PermissionSet
@{
    var NotHave = new MultiSelectList(Model.NotHaveList, "Id", "Role");
 }

@Html.ListBoxFor(model => model.NotHaveList, NotHave, new { @size = "30", id = "possible" });    

@{
    var Have = new MultiSelectList(@Model.HaveList, "Id", "Role");
 }

 @Html.ListBoxFor(model => model.HaveList, Have, new { @size = "30", id = "have" });