Table of Contents

Class ModelBinderAttribute

Namespace
System.Web.Http.ModelBinding
Assembly
System.Web.Http.dll

Specify this parameter uses a model binder. This can optionally specify the specific model binder and value providers that drive that model binder. Derived attributes may provide convenience settings for the model binder or value provider.

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
public class ModelBinderAttribute : ParameterBindingAttribute
Inheritance
ModelBinderAttribute
Derived
Inherited Members

Constructors

ModelBinderAttribute()

Initializes a new instance of the ModelBinderAttribute class.

public ModelBinderAttribute()

ModelBinderAttribute(Type)

Initializes a new instance of the ModelBinderAttribute class.

public ModelBinderAttribute(Type binderType)

Parameters

binderType Type

The type of model binder.

Properties

BinderType

Gets or sets the type of model binder.

public Type BinderType { get; set; }

Property Value

Type

The type of model binder.

Name

Gets or sets the name to consider as the parameter name during model binding.

public string Name { get; set; }

Property Value

string

The parameter name to consider.

SuppressPrefixCheck

Gets or sets a value that specifies whether the prefix check should be suppressed.

public bool SuppressPrefixCheck { get; set; }

Property Value

bool

true if the prefix check should be suppressed; otherwise, false.

Methods

GetBinding(HttpParameterDescriptor)

Gets the binding for a parameter.

public override HttpParameterBinding GetBinding(HttpParameterDescriptor parameter)

Parameters

parameter HttpParameterDescriptor

The parameter to bind.

Returns

HttpParameterBinding

The HttpParameterBindingthat contains the binding.

GetModelBinder(HttpConfiguration, Type)

Get the IModelBinder for this type.

public IModelBinder GetModelBinder(HttpConfiguration configuration, Type modelType)

Parameters

configuration HttpConfiguration

The configuration.

modelType Type

model type that the binder is expected to bind.

Returns

IModelBinder

a non-null model binder.

GetModelBinderProvider(HttpConfiguration)

Gets the model binder provider.

public ModelBinderProvider GetModelBinderProvider(HttpConfiguration configuration)

Parameters

configuration HttpConfiguration

The HttpConfiguration configuration object.

Returns

ModelBinderProvider

The ModelBinderProvider instance.

GetValueProviderFactories(HttpConfiguration)

Gets the value providers that will be fed to the model binder.

public virtual IEnumerable<ValueProviderFactory> GetValueProviderFactories(HttpConfiguration configuration)

Parameters

configuration HttpConfiguration

The HttpConfiguration configuration object.

Returns

IEnumerable<ValueProviderFactory>

A collection of ValueProviderFactory instances.