For example, I like my ModelBinder to transform all "field_???" values to my single custom object. How I could do that? ValueProvider.GetValue only allows me to access by exact name, and I can't enumerate all possible fields...
Asked
Active
Viewed 164 times
1 Answers
1
Try this:
public IActionResult OnPost([Bind(Prefix = "field_")] Whatever model)
Read the article https://learn.microsoft.com/ru-ru/aspnet/core/mvc/models/model-binding?view=aspnetcore-5.0

feihoa
- 477
- 4
- 10
-
Ok, it will call my binder, but inside binder I still can't enumerate fields. Or I'm missing something? – Leotsarev Jun 23 '21 at 08:08
-
Perhaps you need a custom model binder and reflection. Try to take a look: https://learn.microsoft.com/en-us/aspnet/core/mvc/advanced/custom-model-binding?view=aspnetcore-5.0 – feihoa Jun 23 '21 at 08:46