Share via


ApiController.BadRequest Method

Definition

Overloads

BadRequest()

Creates a BadRequestResult (400 Bad Request).

BadRequest(ModelStateDictionary)

Creates an InvalidModelStateResult (400 Bad Request) with the specified model state.

BadRequest(String)

Creates a BadRequestErrorMessageResult (400 Bad Request) with the specified error message.

BadRequest()

Source:
ApiController.cs
Source:
ApiController.cs

Creates a BadRequestResult (400 Bad Request).

[Microsoft.AspNetCore.Mvc.NonAction]
public virtual Microsoft.AspNetCore.Mvc.BadRequestResult BadRequest ();
[<Microsoft.AspNetCore.Mvc.NonAction>]
abstract member BadRequest : unit -> Microsoft.AspNetCore.Mvc.BadRequestResult
override this.BadRequest : unit -> Microsoft.AspNetCore.Mvc.BadRequestResult
Public Overridable Function BadRequest () As BadRequestResult

Returns

A BadRequestResult.

Attributes

Applies to

BadRequest(ModelStateDictionary)

Source:
ApiController.cs
Source:
ApiController.cs

Creates an InvalidModelStateResult (400 Bad Request) with the specified model state.

[Microsoft.AspNetCore.Mvc.NonAction]
public virtual System.Web.Http.InvalidModelStateResult BadRequest (Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary modelState);
[<Microsoft.AspNetCore.Mvc.NonAction>]
abstract member BadRequest : Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary -> System.Web.Http.InvalidModelStateResult
override this.BadRequest : Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary -> System.Web.Http.InvalidModelStateResult
Public Overridable Function BadRequest (modelState As ModelStateDictionary) As InvalidModelStateResult

Parameters

modelState
ModelStateDictionary

The model state to include in the error.

Returns

An InvalidModelStateResult with the specified model state.

Attributes

Applies to

BadRequest(String)

Source:
ApiController.cs
Source:
ApiController.cs

Creates a BadRequestErrorMessageResult (400 Bad Request) with the specified error message.

[Microsoft.AspNetCore.Mvc.NonAction]
public virtual System.Web.Http.BadRequestErrorMessageResult BadRequest (string message);
[<Microsoft.AspNetCore.Mvc.NonAction>]
abstract member BadRequest : string -> System.Web.Http.BadRequestErrorMessageResult
override this.BadRequest : string -> System.Web.Http.BadRequestErrorMessageResult
Public Overridable Function BadRequest (message As String) As BadRequestErrorMessageResult

Parameters

message
String

The user-visible error message.

Returns

A BadRequestErrorMessageResult with the specified error message.

Attributes

Applies to