Table of Contents

Class InvalidModelStateResult

Namespace
System.Web.Http.Results
Assembly
System.Web.Http.dll

Represents an action result that returns a BadRequest response and performs content negotiation on an HttpError based on a ModelStateDictionary.

public class InvalidModelStateResult : IHttpActionResult
Inheritance
InvalidModelStateResult
Implements
Inherited Members

Constructors

InvalidModelStateResult(ModelStateDictionary, bool, IContentNegotiator, HttpRequestMessage, IEnumerable<MediaTypeFormatter>)

Initializes a new instance of the InvalidModelStateResult class.

public InvalidModelStateResult(ModelStateDictionary modelState, bool includeErrorDetail, IContentNegotiator contentNegotiator, HttpRequestMessage request, IEnumerable<MediaTypeFormatter> formatters)

Parameters

modelState ModelStateDictionary

The model state to include in the error.

includeErrorDetail bool

true if the error should include exception messages; otherwise, false.

contentNegotiator IContentNegotiator

The content negotiator to handle content negotiation.

request HttpRequestMessage

The request message which led to this result.

formatters IEnumerable<MediaTypeFormatter>

The formatters to use to negotiate and format the content.

InvalidModelStateResult(ModelStateDictionary, ApiController)

Initializes a new instance of the InvalidModelStateResult class.

public InvalidModelStateResult(ModelStateDictionary modelState, ApiController controller)

Parameters

modelState ModelStateDictionary

The model state to include in the error.

controller ApiController

The controller from which to obtain the dependencies needed for execution.

Properties

ContentNegotiator

Gets the content negotiator to handle content negotiation.

public IContentNegotiator ContentNegotiator { get; }

Property Value

IContentNegotiator

The content negotiator to handle content negotiation.

Formatters

Gets the formatters to use to negotiate and format the content.

public IEnumerable<MediaTypeFormatter> Formatters { get; }

Property Value

IEnumerable<MediaTypeFormatter>

The formatters to use to negotiate and format the content.

IncludeErrorDetail

Gets a value indicating whether the error should include exception messages.

public bool IncludeErrorDetail { get; }

Property Value

bool

true if the error should include exception messages; otherwise, false.

ModelState

Gets the model state to include in the error.

public ModelStateDictionary ModelState { get; }

Property Value

ModelStateDictionary

The model state to include in the error.

Request

Gets the request message which led to this result.

public HttpRequestMessage Request { get; }

Property Value

HttpRequestMessage

The request message which led to this result.

Methods

ExecuteAsync(CancellationToken)

Creates a response message asynchronously.

public virtual Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<HttpResponseMessage>

A task that, when completed, contains the response message.