Share via


HttpRequestMessageExtensions.CreateResponse Method

Definition

Overloads

CreateResponse<T>(HttpRequestMessage, T)

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

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T)

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

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, IEnumerable<MediaTypeFormatter>)

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

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, MediaTypeFormatter)

Helper method that creates a HttpResponseMessage with an System.Net.Http.ObjectContent`1 instance containing the provided value and the given formatter.

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, MediaTypeHeaderValue)

Helper method that creates a HttpResponseMessage with an System.Net.Http.ObjectContent`1 instance containing the provided value. The given mediaType is used to find an instance of System.Net.Http.Formatting.MediaTypeFormatter.

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, String)

Helper method that creates a HttpResponseMessage with an System.Net.Http.ObjectContent`1 instance containing the provided value. The given mediaType is used to find an instance of System.Net.Http.Formatting.MediaTypeFormatter.

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, MediaTypeFormatter, MediaTypeHeaderValue)

Helper method that creates a HttpResponseMessage with an System.Net.Http.ObjectContent`1 instance containing the provided value and the given formatter.

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, MediaTypeFormatter, String)

Helper method that creates a HttpResponseMessage with an System.Net.Http.ObjectContent`1 instance containing the provided value and the given formatter.

CreateResponse<T>(HttpRequestMessage, T)

Source:
HttpRequestMessageExtensions.cs
Source:
HttpRequestMessageExtensions.cs

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

public static System.Net.Http.HttpResponseMessage CreateResponse<T> (this System.Net.Http.HttpRequestMessage request, T value);
static member CreateResponse : System.Net.Http.HttpRequestMessage * 'T -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateResponse(Of T) (request As HttpRequestMessage, value As T) As HttpResponseMessage

Type Parameters

T

The type of the value.

Parameters

request
HttpRequestMessage

The request.

value
T

The value to wrap. Can be null.

Returns

A response wrapping value with OK status code.

Remarks

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

Applies to

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T)

Source:
HttpRequestMessageExtensions.cs
Source:
HttpRequestMessageExtensions.cs

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

public static System.Net.Http.HttpResponseMessage CreateResponse<T> (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, T value);
static member CreateResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * 'T -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateResponse(Of T) (request As HttpRequestMessage, statusCode As HttpStatusCode, value As T) As HttpResponseMessage

Type Parameters

T

The type of the value.

Parameters

request
HttpRequestMessage

The request.

statusCode
HttpStatusCode

The status code of the created response.

value
T

The value to wrap. Can be null.

Returns

A response wrapping value with statusCode.

Remarks

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

Applies to

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, IEnumerable<MediaTypeFormatter>)

Source:
HttpRequestMessageExtensions.cs
Source:
HttpRequestMessageExtensions.cs

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

public static System.Net.Http.HttpResponseMessage CreateResponse<T> (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, T value, System.Collections.Generic.IEnumerable<System.Net.Http.Formatting.MediaTypeFormatter> formatters);
static member CreateResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * 'T * seq<System.Net.Http.Formatting.MediaTypeFormatter> -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateResponse(Of T) (request As HttpRequestMessage, statusCode As HttpStatusCode, value As T, formatters As IEnumerable(Of MediaTypeFormatter)) As HttpResponseMessage

Type Parameters

T

The type of the value.

Parameters

request
HttpRequestMessage

The request.

statusCode
HttpStatusCode

The status code of the created response.

value
T

The value to wrap. Can be null.

formatters
IEnumerable<System.Net.Http.Formatting.MediaTypeFormatter>

The set of System.Net.Http.Formatting.MediaTypeFormatter objects from which to choose.

Returns

A response wrapping value with statusCode.

Remarks

This method will get the HttpContext instance associated with request.

Applies to

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, MediaTypeFormatter)

Source:
HttpRequestMessageExtensions.cs
Source:
HttpRequestMessageExtensions.cs

Helper method that creates a HttpResponseMessage with an System.Net.Http.ObjectContent`1 instance containing the provided value and the given formatter.

public static System.Net.Http.HttpResponseMessage CreateResponse<T> (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, T value, System.Net.Http.Formatting.MediaTypeFormatter formatter);
static member CreateResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * 'T * System.Net.Http.Formatting.MediaTypeFormatter -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateResponse(Of T) (request As HttpRequestMessage, statusCode As HttpStatusCode, value As T, formatter As MediaTypeFormatter) As HttpResponseMessage

Type Parameters

T

The type of the value.

Parameters

request
HttpRequestMessage

The request.

statusCode
HttpStatusCode

The status code of the created response.

value
T

The value to wrap. Can be null.

formatter
System.Net.Http.Formatting.MediaTypeFormatter

The formatter to use.

Returns

A response wrapping value with statusCode.

Applies to

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, MediaTypeHeaderValue)

Source:
HttpRequestMessageExtensions.cs
Source:
HttpRequestMessageExtensions.cs

Helper method that creates a HttpResponseMessage with an System.Net.Http.ObjectContent`1 instance containing the provided value. The given mediaType is used to find an instance of System.Net.Http.Formatting.MediaTypeFormatter.

public static System.Net.Http.HttpResponseMessage CreateResponse<T> (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, T value, System.Net.Http.Headers.MediaTypeHeaderValue mediaType);
static member CreateResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * 'T * System.Net.Http.Headers.MediaTypeHeaderValue -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateResponse(Of T) (request As HttpRequestMessage, statusCode As HttpStatusCode, value As T, mediaType As MediaTypeHeaderValue) As HttpResponseMessage

Type Parameters

T

The type of the value.

Parameters

request
HttpRequestMessage

The request.

statusCode
HttpStatusCode

The status code of the created response.

value
T

The value to wrap. Can be null.

mediaType
MediaTypeHeaderValue

The media type used to look up an instance of System.Net.Http.Formatting.MediaTypeFormatter.

Returns

A response wrapping value with statusCode.

Applies to

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, String)

Source:
HttpRequestMessageExtensions.cs
Source:
HttpRequestMessageExtensions.cs

Helper method that creates a HttpResponseMessage with an System.Net.Http.ObjectContent`1 instance containing the provided value. The given mediaType is used to find an instance of System.Net.Http.Formatting.MediaTypeFormatter.

public static System.Net.Http.HttpResponseMessage CreateResponse<T> (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, T value, string mediaType);
static member CreateResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * 'T * string -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateResponse(Of T) (request As HttpRequestMessage, statusCode As HttpStatusCode, value As T, mediaType As String) As HttpResponseMessage

Type Parameters

T

The type of the value.

Parameters

request
HttpRequestMessage

The request.

statusCode
HttpStatusCode

The status code of the created response.

value
T

The value to wrap. Can be null.

mediaType
String

The media type used to look up an instance of System.Net.Http.Formatting.MediaTypeFormatter.

Returns

A response wrapping value with statusCode.

Applies to

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, MediaTypeFormatter, MediaTypeHeaderValue)

Source:
HttpRequestMessageExtensions.cs
Source:
HttpRequestMessageExtensions.cs

Helper method that creates a HttpResponseMessage with an System.Net.Http.ObjectContent`1 instance containing the provided value and the given formatter.

public static System.Net.Http.HttpResponseMessage CreateResponse<T> (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, T value, System.Net.Http.Formatting.MediaTypeFormatter formatter, System.Net.Http.Headers.MediaTypeHeaderValue mediaType);
static member CreateResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * 'T * System.Net.Http.Formatting.MediaTypeFormatter * System.Net.Http.Headers.MediaTypeHeaderValue -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateResponse(Of T) (request As HttpRequestMessage, statusCode As HttpStatusCode, value As T, formatter As MediaTypeFormatter, mediaType As MediaTypeHeaderValue) As HttpResponseMessage

Type Parameters

T

The type of the value.

Parameters

request
HttpRequestMessage

The request.

statusCode
HttpStatusCode

The status code of the created response.

value
T

The value to wrap. Can be null.

formatter
System.Net.Http.Formatting.MediaTypeFormatter

The formatter to use.

mediaType
MediaTypeHeaderValue

The media type override to set on the response's content. Can be null.

Returns

A response wrapping value with statusCode.

Applies to

CreateResponse<T>(HttpRequestMessage, HttpStatusCode, T, MediaTypeFormatter, String)

Source:
HttpRequestMessageExtensions.cs
Source:
HttpRequestMessageExtensions.cs

Helper method that creates a HttpResponseMessage with an System.Net.Http.ObjectContent`1 instance containing the provided value and the given formatter.

public static System.Net.Http.HttpResponseMessage CreateResponse<T> (this System.Net.Http.HttpRequestMessage request, System.Net.HttpStatusCode statusCode, T value, System.Net.Http.Formatting.MediaTypeFormatter formatter, string mediaType);
static member CreateResponse : System.Net.Http.HttpRequestMessage * System.Net.HttpStatusCode * 'T * System.Net.Http.Formatting.MediaTypeFormatter * string -> System.Net.Http.HttpResponseMessage
<Extension()>
Public Function CreateResponse(Of T) (request As HttpRequestMessage, statusCode As HttpStatusCode, value As T, formatter As MediaTypeFormatter, mediaType As String) As HttpResponseMessage

Type Parameters

T

The type of the value.

Parameters

request
HttpRequestMessage

The request.

statusCode
HttpStatusCode

The status code of the created response.

value
T

The value to wrap. Can be null.

formatter
System.Net.Http.Formatting.MediaTypeFormatter

The formatter to use.

mediaType
String

The media type override to set on the response's content. Can be null.

Returns

A response wrapping value with statusCode.

Applies to