I'm working on a .NET Core 2 API project and have been trying to implement a universal string trim model binder that would trim all string values of provided request parameters and field values. So far I have had mixed results and am struggling to find working example that would point me in the right direction. I've been trying to implement the same model binder as [posted by Vikash Kumar](https://vikutech.blogspot.com/2018/02/trim-text-in-mvc-core-through-model-binder.html).

This model binder works fine for all string values that are passed into controller actions via direct parameters, such as `public IActionResult Profile(string username)`, but for string fields in complex objects the `BindModelAsync` method of the `TrimmingModelBinder` class never gets called. An example of an HttpPost action in my controller would be `public IActionResult Profile([FormBody] ProfileLookupModel model)`. The model binder does not seem to check the fields of the complex model. It also doesn't work for fields that are Lists of strings.

I recall prior to .NET Core, specifying a string trim model binder would recursively check each field of complex models, even models within complex models. This doesn't seem to be the case in .NET Core, but I might be wrong. My project is targeting the `netcoreapp2.0` framework.

I'm curious if anyone has had the same issue as me and possibly found a solution for it.

Note: I haven't posted any sample code as it is the same as the code from the referenced article.