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.ActionContext associated 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.BindingSource associated with the Microsoft.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.HttpContext associated 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.IValueProvider during 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.ModelStateDictionary used to capture Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.ModelState values 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.ModelBindingResult which represents the result of the model binding process. </p> <p> Before an Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinder is called, Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.Result will be set to a value indicating failure. The binder should set Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.Result to a value created with Microsoft.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.IValueProvider associated 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.NestedScope scope 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:
Return type:

Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.NestedScope

Returns:

A Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext.NestedScope scope 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)
ExitNestedScope()

Removes a layer of state pushed by calling EnterNestedScope.

protected abstract void ExitNestedScope()