MvcOptionsExtensions Class
HAKOM.ErrorHandling.Http.Net.Api.Extensions
Section titled “HAKOM.ErrorHandling.Http.Net.Api.Extensions”Extension methods for adding error-handling features to an application using Microsofts MVC framework.
public static class MvcOptionsExtensionsInheritance System.Object 🡒 MvcOptionsExtensions
Methods
Section titled “Methods”MvcOptionsExtensions.AddProblemDetailsFormatter(this MvcOptions) Method
Section titled “MvcOptionsExtensions.AddProblemDetailsFormatter(this MvcOptions) Method”Adds RFC7807 compliant formatting of errors to the application.
public static Microsoft.AspNetCore.Mvc.MvcOptions AddProblemDetailsFormatter(this Microsoft.AspNetCore.Mvc.MvcOptions mvcOptions);Parameters
Section titled “Parameters”mvcOptions Microsoft.AspNetCore.Mvc.MvcOptions
The Microsoft.AspNetCore.Mvc.MvcOptions of the application to add error output to.
Returns
Section titled “Returns”Microsoft.AspNetCore.Mvc.MvcOptions
The mvcOptions themselves for chaining additional configuration.
Remarks
Section titled “Remarks”Adds a Microsoft.AspNetCore.Mvc.Formatters.IOutputFormatter that can produce RFC7807 compliant application/problem+json responses from intances of
- System.Exception (or any type derived thereof),
- Microsoft.AspNetCore.Mvc.ProblemDetails (or any type derived thereof),
- Failure,
- Failure<TValue>
This should be added after all other custom output formatters have been added to the Microsoft.AspNetCore.Mvc.MvcOptions.OutputFormatters collection, otherwise it may have no effect.
MvcOptionsExtensions.AddSuccessResultFormatter(this MvcOptions) Method
Section titled “MvcOptionsExtensions.AddSuccessResultFormatter(this MvcOptions) Method”Adds implicit Result to Success/Success<TValue> conversion to the application.
public static Microsoft.AspNetCore.Mvc.MvcOptions AddSuccessResultFormatter(this Microsoft.AspNetCore.Mvc.MvcOptions mvcOptions);Parameters
Section titled “Parameters”mvcOptions Microsoft.AspNetCore.Mvc.MvcOptions
The Microsoft.AspNetCore.Mvc.MvcOptions of the application to add success conversion to.
Returns
Section titled “Returns”Microsoft.AspNetCore.Mvc.MvcOptions
The mvcOptions themselves for chaining additional configuration.
Remarks
Section titled “Remarks”Adds a Microsoft.AspNetCore.Mvc.Formatters.IOutputFormatter that can convert into values as application/json responses from intances of
This should be added after all other custom output formatters have been added to the Microsoft.AspNetCore.Mvc.MvcOptions.OutputFormatters collection, otherwise it may have no effect.
MvcOptionsExtensions.ReturnBadRequestOnExtraneousQueryParameters(this MvcOptions) Method
Section titled “MvcOptionsExtensions.ReturnBadRequestOnExtraneousQueryParameters(this MvcOptions) Method”Adds a filter to the request pipeline that makes checks if the client passed any query parameters not supported by the endpoint. If so, it short-circuits the rest of the request and responds with a 400 (Bad Request) response.
public static Microsoft.AspNetCore.Mvc.MvcOptions ReturnBadRequestOnExtraneousQueryParameters(this Microsoft.AspNetCore.Mvc.MvcOptions mvcOptions);Parameters
Section titled “Parameters”mvcOptions Microsoft.AspNetCore.Mvc.MvcOptions
The Microsoft.AspNetCore.Mvc.MvcOptions used to configure the application.
Returns
Section titled “Returns”Microsoft.AspNetCore.Mvc.MvcOptions
The mvcOptions themselves for chaining additional configuration.