You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
The TryUpdateModel methods require that you explicitly declare the type you are binding at compile time, and if you attempt to bind a subclass instance the subclass properties are ignored. This is because the model metadata is requested using the type parameter:
var modelMetadata = metadataProvider.GetMetadataForType(
modelAccessor: null,
modelType: typeof(TModel));
...instead of using the type of the model instance:
var modelMetadata = metadataProvider.GetMetadataForType(
modelAccessor: null,
modelType: model.GetType());
Even with this small change you are still forced to provide the TModel type parameter, but at least you can pass a base type for TModel and have a derived instance be properly updated.