ModelBindingContext Class¶
A context that contains operating information for model binding and validation.
- Namespace
Microsoft.AspNetCore.Mvc.ModelBinding- Assemblies
- Microsoft.AspNetCore.Mvc.Abstractions
Syntax¶
public abstract class ModelBindingContext
-
class
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext
Properties¶
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.ActionContext¶ Represents the
Microsoft.AspNetCore.Mvc.ActionContextassociated with this context.Return type: Microsoft.AspNetCore.Mvc.ActionContext public abstract ActionContext ActionContext { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.BinderModelName¶ Gets or sets a model name which is explicitly set using an
Microsoft.AspNetCore.Mvc.ModelBinding.IModelNameProvider.Return type: System.String public abstract string BinderModelName { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.BindingSource¶ Gets or sets a value which represents the
Microsoft.AspNetCore.Mvc.ModelBinding.BindingSourceassociated with theMicrosoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.Model.Return type: Microsoft.AspNetCore.Mvc.ModelBinding.BindingSource public abstract BindingSource BindingSource { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.FieldName¶ Gets or sets the name of the current field being bound.
Return type: System.String public abstract string FieldName { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.HttpContext¶ Gets the
Microsoft.AspNetCore.Http.HttpContextassociated with this context.Return type: Microsoft.AspNetCore.Http.HttpContext public virtual HttpContext HttpContext { get; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.IsTopLevelObject¶ Gets or sets an indication that the current binder is handling the top-level object.
Return type: System.Boolean public abstract bool IsTopLevelObject { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.Model¶ Gets or sets the model value for the current operation.
Return type: System.Object public abstract object Model { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.ModelMetadata¶ Gets or sets the metadata for the model associated with this context.
Return type: Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata public abstract ModelMetadata ModelMetadata { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.ModelName¶ Gets or sets the name of the model. This property is used as a key for looking up values in
Microsoft.AspNetCore.Mvc.ModelBinding.IValueProviderduring model binding.Return type: System.String public abstract string ModelName { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.ModelState¶ Gets or sets the
Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionaryused to captureMicrosoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.ModelStatevalues for properties in the object graph of the model when binding.Return type: Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary public abstract ModelStateDictionary ModelState { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.ModelType¶ Gets the type of the model.
Return type: System.Type public virtual Type ModelType { get; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.PropertyFilter¶ Gets or sets a predicate which will be evaluated for each property to determine if the property is eligible for model binding.
Return type: System.Func<Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata> public abstract Func<ModelMetadata, bool> PropertyFilter { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.Result¶ <p> Gets or sets a
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResultwhich represents the result of the model binding process. </p> <p> Before anMicrosoft.AspNetCore.Mvc.ModelBinding.IModelBinderis called,Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.Resultwill be set to a value indicating failure. The binder should setMicrosoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.Resultto a value created withMicrosoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult.Success(System.Object)if model binding succeeded. </p>Return type: Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingResult public abstract ModelBindingResult Result { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.ValidationState¶ Gets or sets the
Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationStateDictionary. Used for tracking validation state to customize validation behavior for a model object.Return type: Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationStateDictionary public abstract ValidationStateDictionary ValidationState { get; set; }
-
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.ValueProvider¶ Gets or sets the
Microsoft.AspNetCore.Mvc.ModelBinding.IValueProviderassociated with this context.Return type: Microsoft.AspNetCore.Mvc.ModelBinding.IValueProvider public abstract IValueProvider ValueProvider { get; set; }
-
Methods¶
-
EnterNestedScope()¶ Pushes a layer of state onto this context. Model binders will call this as part of recursion when binding properties or collection items.
Return type: Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.NestedScope Returns: A Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.NestedScopescope object which should be used in a using statement where PushContext is called.public abstract ModelBindingContext.NestedScope EnterNestedScope()
-
EnterNestedScope(Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata, System.String, System.String, System.Object) Pushes a layer of state onto this context. Model binders will call this as part of recursion when binding properties or collection items.
Arguments: - modelMetadata (Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata) –
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadatato assign to theMicrosoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.ModelMetadataproperty. - fieldName (System.String) – Name to assign to the
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.FieldNameproperty. - modelName (System.String) – Name to assign to the
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.ModelNameproperty. - model (System.Object) – Instance to assign to the
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.Modelproperty.
Return type: Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.NestedScope
Returns: A
Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.NestedScopescope object which should be used in a using statement where PushContext is called.public abstract ModelBindingContext.NestedScope EnterNestedScope(ModelMetadata modelMetadata, string fieldName, string modelName, object model)
- modelMetadata (Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata) –
-
ExitNestedScope()¶ Removes a layer of state pushed by calling
EnterNestedScope.protected abstract void ExitNestedScope()
-