Posting MVC-actionlink List of complex type

I have an actionlink that, when clicked, im passes the list of objects to the controller action.

Example:

View:

Html.ActionLink("TestLink", "TestMethod", "Test", Model.SampleList, null)

TestController:

public ActionResult TestMethod(List<SampleList> sampleList)  
{  
  return View(sampleList);  
}

When I do this, I get a null sampleList. I can only transfer one complex object, not its collection. Do I need the correct routing? The reason I do this is that instead of passing the identifier and searching in the controller action, I just pass the data.

+3
source share
1 answer

, , . , , , HtmlHelper, :

, .

, .

+2

Source: https://habr.com/ru/post/1738358/


All Articles