Table of Contents

Class ControllerBaseExtensions

Namespace
MADE.Web.Mvc.Extensions
Assembly
MADE.Web.Mvc.dll

Defines a collection of extensions for MVC ControllerBase instances.

public static class ControllerBaseExtensions
Inheritance
ControllerBaseExtensions
Inherited Members

Methods

Forbidden(ControllerBase, ModelStateDictionary)

Creates a ForbiddenObjectResult that produces a Status403Forbidden response.

public static IActionResult Forbidden(this ControllerBase controller, ModelStateDictionary modelState)

Parameters

controller ControllerBase

The controller that is performing the response.

modelState ModelStateDictionary

The ModelStateDictionary containing errors to be returned to the client.

Returns

IActionResult

The created ForbiddenObjectResult for the response.

Exceptions

ArgumentNullException

Thrown if the controller or modelState is null.

Forbidden(ControllerBase, object)

Creates a ForbiddenObjectResult that produces a Status403Forbidden response.

public static IActionResult Forbidden(this ControllerBase controller, object responseContent)

Parameters

controller ControllerBase

The controller that is performing the response.

responseContent object

An error object to be returned to the client.

Returns

IActionResult

The created ForbiddenObjectResult for the response.

Exceptions

ArgumentNullException

Thrown if the controller is null.

InternalServerError(ControllerBase, ModelStateDictionary)

public static IActionResult InternalServerError(this ControllerBase controller, ModelStateDictionary modelState)

Parameters

controller ControllerBase

The controller that is performing the response.

modelState ModelStateDictionary

The ModelStateDictionary containing errors to be returned to the client.

Returns

IActionResult

The created BadRequestObjectResult for the response.

Exceptions

ArgumentNullException

Thrown if the controller or modelState is null.

InternalServerError(ControllerBase, object)

public static IActionResult InternalServerError(this ControllerBase controller, object responseContent)

Parameters

controller ControllerBase

The controller that is performing the response.

responseContent object

An error object to be returned to the client.

Returns

IActionResult

The created BadRequestObjectResult for the response.

Exceptions

ArgumentNullException

Thrown if the controller is null.

Json(ControllerBase, object, HttpStatusCode, JsonSerializerOptions?)

Creates a JsonResult object from the specified value for a controller response.

public static IActionResult Json(this ControllerBase controller, object value, HttpStatusCode statusCode = HttpStatusCode.OK, JsonSerializerOptions? serializerOptions = null)

Parameters

controller ControllerBase

The controller that is performing the response.

value object

The value object to serialize.

statusCode HttpStatusCode

The expected result HTTP status code.

serializerOptions JsonSerializerOptions

The JSON serializer options for serializing the result.

Returns

IActionResult

The created JsonResult for the response.

Exceptions

ArgumentNullException

Thrown if the controller is null.