I want to pass data from the view to controller with Html.beginform. The caregiverid is null. This should work but I don't know what I do wrong. I also checked the variable names, but it is the same.
I also tested, if the viewbag is filled with data. The viewbag is filled with the correct data.
This is the view
@using (Html.BeginForm("PairClient", "Admin", FormMethod.Post, new { @class = "col-md-12", caregiverid = ViewBag.caregiverid }))
{
    <select name="clientselect" class="selectpicker" data-live-search="true" data-actions-box="true" data-selected-text-format="count > 4" data-multiple-separator=" | " data-none-selected-text="Niks geselecteerd" data-deselect-all-text="Niks" data-select-all-text="Alles" data-count-selected-text="{0} clienten geselecteerd" data-width="100%" data-size="10" multiple>
        @foreach (var client in Model)
        {
            <option style="font-size:15px;" value="@client.ClientId" selected="@(client.IsSelected ? "selected" : null)" data-tokens="@client.Email">@client.SocialNumber - @client.Firstname @client.Lastname</option>
        }
    </select>
    <input class="btn btn-success " type="submit" value="Koppel cliënt" />
}
This is the controller
[HttpPost]
public IActionResult PairClient(string caregiverid, string[] clientselect)
{
    string token = Request.Cookies["userToken"];
    admin.PairClient(token, caregiverid, clientselect);
    return RedirectToAction("Singlecaregiver");
}
It worked! I do not know what I have changed... but somehow it worked
 
     
    

 
    