InvalidModelStateResult Class

An action result that returns a Microsoft.AspNetCore.Http.StatusCodes.Status400BadRequest response and performs content negotiation on an System.Web.Http.HttpError based on a Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary.

Namespace
System.Web.Http
Assemblies
  • Microsoft.AspNetCore.Mvc.WebApiCompatShim

Syntax

public class InvalidModelStateResult : ObjectResult, IActionResult
class System.Web.Http.InvalidModelStateResult

Constructors

InvalidModelStateResult(Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary, System.Boolean)

Initializes a new instance of the System.Web.Http.InvalidModelStateResult class.

Arguments:
  • modelState (Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary) – The model state to include in the error.
  • includeErrorDetail (System.Boolean) – <xref uid=”langword_csharp_true” name=”true” href=”“></xref> if the error should include exception messages; otherwise, <xref uid=”langword_csharp_false” name=”false” href=”“></xref>.
public InvalidModelStateResult(ModelStateDictionary modelState, bool includeErrorDetail)

Methods

ExecuteResultAsync(Microsoft.AspNetCore.Mvc.ActionContext)
Return type:System.Threading.Tasks.Task
public override Task ExecuteResultAsync(ActionContext context)

Properties

System.Web.Http.InvalidModelStateResult.IncludeErrorDetail

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

Return type:System.Boolean
public bool IncludeErrorDetail { get; }
System.Web.Http.InvalidModelStateResult.ModelState

Gets the model state to include in the error.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary
public ModelStateDictionary ModelState { get; }