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
controllerControllerBaseThe controller that is performing the response.
modelStateModelStateDictionaryThe ModelStateDictionary containing errors to be returned to the client.
Returns
- IActionResult
The created ForbiddenObjectResult for the response.
Exceptions
- ArgumentNullException
Thrown if the
controllerormodelStateis null.
Forbidden(ControllerBase, object)
Creates a ForbiddenObjectResult that produces a Status403Forbidden response.
public static IActionResult Forbidden(this ControllerBase controller, object responseContent)
Parameters
controllerControllerBaseThe controller that is performing the response.
responseContentobjectAn error object to be returned to the client.
Returns
- IActionResult
The created ForbiddenObjectResult for the response.
Exceptions
- ArgumentNullException
Thrown if the
controlleris null.
InternalServerError(ControllerBase, ModelStateDictionary)
Creates an InternalServerErrorObjectResult that produces a Status500InternalServerError response.
public static IActionResult InternalServerError(this ControllerBase controller, ModelStateDictionary modelState)
Parameters
controllerControllerBaseThe controller that is performing the response.
modelStateModelStateDictionaryThe ModelStateDictionary containing errors to be returned to the client.
Returns
- IActionResult
The created BadRequestObjectResult for the response.
Exceptions
- ArgumentNullException
Thrown if the
controllerormodelStateis null.
InternalServerError(ControllerBase, object)
Creates an InternalServerErrorObjectResult that produces a Status500InternalServerError response.
public static IActionResult InternalServerError(this ControllerBase controller, object responseContent)
Parameters
controllerControllerBaseThe controller that is performing the response.
responseContentobjectAn error object to be returned to the client.
Returns
- IActionResult
The created BadRequestObjectResult for the response.
Exceptions
- ArgumentNullException
Thrown if the
controlleris 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
controllerControllerBaseThe controller that is performing the response.
valueobjectThe value object to serialize.
statusCodeHttpStatusCodeThe expected result HTTP status code.
serializerOptionsJsonSerializerOptionsThe JSON serializer options for serializing the result.
Returns
- IActionResult
The created JsonResult for the response.
Exceptions
- ArgumentNullException
Thrown if the
controlleris null.