HttpRequestMessageExtensions.CreateErrorResponse HttpRequestMessageExtensions.CreateErrorResponse HttpRequestMessageExtensions.CreateErrorResponse Method

Definition

Overloads

CreateErrorResponse(HttpRequestMessage, HttpStatusCode, ModelStateDictionary) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, ModelStateDictionary) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, ModelStateDictionary)

Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of System.Net.Http.ObjectContent`1 wrapping an HttpError for model state modelState. If no formatter is found, this method returns a response with status 406 NotAcceptable.

CreateErrorResponse(HttpRequestMessage, HttpStatusCode, Exception) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, Exception)

Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of System.Net.Http.ObjectContent`1 wrapping an HttpError for exception exception. If no formatter is found, this method returns a response with status 406 NotAcceptable.

CreateErrorResponse(HttpRequestMessage, HttpStatusCode, String) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, String) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, String)

Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of System.Net.Http.ObjectContent`1 wrapping an HttpError with message message. If no formatter is found, this method returns a response with status 406 NotAcceptable.

CreateErrorResponse(HttpRequestMessage, HttpStatusCode, HttpError) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, HttpError) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, HttpError)

Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of System.Net.Http.ObjectContent`1 wrapping error as the content. If no formatter is found, this method returns a response with status 406 NotAcceptable.

CreateErrorResponse(HttpRequestMessage, HttpStatusCode, String, Exception) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, String, Exception)

Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of System.Net.Http.ObjectContent`1 wrapping an HttpError with error message message for exception exception. If no formatter is found, this method returns a response with status 406 NotAcceptable.

CreateErrorResponse(HttpRequestMessage, HttpStatusCode, ModelStateDictionary) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, ModelStateDictionary) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, ModelStateDictionary)

Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of System.Net.Http.ObjectContent`1 wrapping an HttpError for model state modelState. If no formatter is found, this method returns a response with status 406 NotAcceptable.

public static System.Net.Http.HttpResponseMessage CreateErrorResponse (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary modelState);
static member CreateErrorResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateErrorResponse (request As HttpRequestMessage, statusCode As HttpStatusCode, modelState As ModelStateDictionary) As HttpResponseMessage

Parameters

statusCode
HttpStatusCode HttpStatusCode HttpStatusCode

The status code of the created response.

Returns

An error response for modelState with status code statusCode.

Remarks

This method requires that request has been associated with an instance of HttpContext.

CreateErrorResponse(HttpRequestMessage, HttpStatusCode, Exception) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, Exception)

Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of System.Net.Http.ObjectContent`1 wrapping an HttpError for exception exception. If no formatter is found, this method returns a response with status 406 NotAcceptable.

public static System.Net.Http.HttpResponseMessage CreateErrorResponse (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, Exception exception);
static member CreateErrorResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * Exception -> System.Net.Http.HttpResponseMessage

Parameters

statusCode
HttpStatusCode HttpStatusCode HttpStatusCode

The status code of the created response.

exception
Exception Exception Exception

The exception.

Returns

An error response for exception with status code statusCode.

Remarks

This method requires that request has been associated with an instance of HttpContext.

CreateErrorResponse(HttpRequestMessage, HttpStatusCode, String) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, String) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, String)

Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of System.Net.Http.ObjectContent`1 wrapping an HttpError with message message. If no formatter is found, this method returns a response with status 406 NotAcceptable.

public static System.Net.Http.HttpResponseMessage CreateErrorResponse (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, string message);
static member CreateErrorResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * string -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateErrorResponse (request As HttpRequestMessage, statusCode As HttpStatusCode, message As String) As HttpResponseMessage

Parameters

statusCode
HttpStatusCode HttpStatusCode HttpStatusCode

The status code of the created response.

message
String String String

The error message.

Returns

An error response with error message message and status code statusCode.

Remarks

This method requires that request has been associated with an instance of HttpContext.

CreateErrorResponse(HttpRequestMessage, HttpStatusCode, HttpError) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, HttpError) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, HttpError)

Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of System.Net.Http.ObjectContent`1 wrapping error as the content. If no formatter is found, this method returns a response with status 406 NotAcceptable.

public static System.Net.Http.HttpResponseMessage CreateErrorResponse (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, System.Web.Http.HttpError error);
static member CreateErrorResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * System.Web.Http.HttpError -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateErrorResponse (request As HttpRequestMessage, statusCode As HttpStatusCode, error As HttpError) As HttpResponseMessage

Parameters

statusCode
HttpStatusCode HttpStatusCode HttpStatusCode

The status code of the created response.

error
HttpError HttpError HttpError

The error to wrap.

Returns

An error response wrapping error with status code statusCode.

Remarks

This method requires that request has been associated with an instance of HttpContext.

CreateErrorResponse(HttpRequestMessage, HttpStatusCode, String, Exception) CreateErrorResponse(HttpRequestMessage, HttpStatusCode, String, Exception)

Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of System.Net.Http.ObjectContent`1 wrapping an HttpError with error message message for exception exception. If no formatter is found, this method returns a response with status 406 NotAcceptable.

public static System.Net.Http.HttpResponseMessage CreateErrorResponse (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, string message, Exception exception);
static member CreateErrorResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * string * Exception -> System.Net.Http.HttpResponseMessage

Parameters

statusCode
HttpStatusCode HttpStatusCode HttpStatusCode

The status code of the created response.

message
String String String

The error message.

exception
Exception Exception Exception

The exception.

Returns

An error response for exception with error message message and status code statusCode.

Remarks

This method requires that request has been associated with an instance of HttpContext.

Applies to