Creating a ModelBinder for MongoDB ObjectId on Asp.Net Core
问题 I'm trying to create a very simple model binder for ObjectId types in my models but can't seem to make it work so far. Here's the model binder: public class ObjectIdModelBinder : IModelBinder { public Task BindModelAsync(ModelBindingContext bindingContext) { var result = bindingContext.ValueProvider.GetValue(bindingContext.FieldName); return Task.FromResult(new ObjectId(result.FirstValue)); } } This is the ModelBinderProvider I've coded: public class ObjectIdModelBinderProvider :