From 3120134835b3c6a1b4620331d4fd1af23831c58c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 2 Dec 2021 14:12:14 -0800 Subject: [PATCH] Update aspnetcore/mvc/models/model-binding.md Co-authored-by: Pranav K --- aspnetcore/mvc/models/model-binding.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aspnetcore/mvc/models/model-binding.md b/aspnetcore/mvc/models/model-binding.md index 46f64eddb3..20ae51744a 100644 --- a/aspnetcore/mvc/models/model-binding.md +++ b/aspnetcore/mvc/models/model-binding.md @@ -967,7 +967,10 @@ For targets that are collections of simple types, model binding looks for matche [a]=1050&[b]=2000&index=a&index=b ``` > [!WARNING] - > Since the model binding looks for the keyword `index` from a Form or Query string is strongly recommended to not use it as your action's parameter name to avoid unexpected behaviors. + > Avoid binding a parameter or a property named `index` or `Index` if it is adjacent to a collection value. Model binding will attempt to use it as the index for the collection which might result in incorrect binding. For example, consider the following action: + + ```csharp + public IActionResult Post(string index, List products) * The following format is supported only in form data: