HttpRequestMessageExtensions.CreateErrorResponse Method (HttpRequestMessage, HttpStatusCode, ODataError)
Helper method that performs content negotiation and creates a HttpResponseMessage representing an error with an instance of ObjectContent<T> wrapping oDataError as the content. If no formatter is found, this method returns a response with status 406 NotAcceptable.
This method requires that request has been associated with an instance of HttpConfiguration.
Namespace: System.Web.Http.OData.Extensions
Assembly: System.Web.Http.OData (in System.Web.Http.OData.dll)
Syntax
public static HttpResponseMessage CreateErrorResponse(
this HttpRequestMessage request,
HttpStatusCode statusCode,
ODataError oDataError
)
public:
[ExtensionAttribute]
static HttpResponseMessage^ CreateErrorResponse(
HttpRequestMessage^ request,
HttpStatusCode statusCode,
ODataError^ oDataError
)
static member CreateErrorResponse :
request:HttpRequestMessage *
statusCode:HttpStatusCode *
oDataError:ODataError -> HttpResponseMessage
<ExtensionAttribute>
Public Shared Function CreateErrorResponse (
request As HttpRequestMessage,
statusCode As HttpStatusCode,
oDataError As ODataError
) As HttpResponseMessage
Parameters
request
Type: System.Net.Http.HttpRequestMessageThe request of interest.
statusCode
Type: System.Net.HttpStatusCodeThe status code of the created response.
oDataError
Type: Microsoft.Data.OData.ODataErrorThe OData error to wrap.
Return Value
Type: System.Net.Http.HttpResponseMessage
An error response wrapping oDataError with status code statusCode.
See Also
HttpRequestMessageExtensions Class
System.Web.Http.OData.Extensions Namespace
Return to top