0

I have a form with 2 select box. But when I click the submit button, there's an error saying "Cannot create an abstract class". I have no idea what is going wrong here

@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" />
}

Admin/Add

[HttpPost]
        public ActionResult Add(Array userIDs, int groupID, string RedirectToUrl)
        {

            return Redirect(RedirectToUrl);
        }

1 Answer 1

2

Array is an abstract class, so MVC has no idea which specific Array implementation to create when binding the parameters. Try something like:

public ActionResult Add(int[] userIDs, int groupID, string RedirectToUrl)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.