Model binding not working on submitting razor view with foreach loop


Why model binding does not work in MVC as expected, if we submit a razor form that contains a foreach loop. The list parameter on the action controller is null or empty. MVC default model binder not working. The values from the form are not mapped to the list parameter.

Text version of the video


ASP.NET Core Text Articles & Slides

ASP.NET Core Tutorial

Angular, JavaScript, jQuery, Dot Net & SQL Playlists


Xem thêm bài viết khác:


  1. Answer lies in difference between by ctford. Great Video Series. thanks KV.

  2. All Videos are excellent. Please Create video on 1) Cookies without identity, 2) Custom role with customized ADD/Edit/Delete rights.

  3. Thanks, But I think it why it better to have a Viewmodel that have a list of userRoles. Then you can use ForeachLoop through the Viewmodel.userRoles and the model Biding will works 😉

  4. The most accomplished teacher on youtube, from content to delivery you are awesome. When are you coming with Udemy or coursera course of building fully fledged core application? I am the first to register, please do it! let us apply what we have learned throughout this series

  5. Hey, how to check email for a forbidden domain? we will have a LIST of forbidden domains against ONE allowed. I can not make this

  6. Thanx for this clearing.
    Hope Microsoft will fix this issue in one of their next versions, because you don't need the indexes of the for-loop, the interpreter can also interprete the foreach loop and counts indexes on it's own …


Please enter your comment!
Please enter your name here