HttpRequestMessageExtensions.CreateResponse<T> Method (HttpRequestMessage, HttpStatusCode, T, String)

Creates an HttpResponseMessage wired up to the associated HttpRequestMessage.

Namespace:  System.Net.Http
Assembly:  System.Web.Http (in System.Web.Http.dll)


<ExtensionAttribute> _
Public Shared Function CreateResponse(Of T) ( _
    request As HttpRequestMessage, _
    statusCode As HttpStatusCode, _
    value As T, _
    mediaType As String _
) As HttpResponseMessage
Dim request As HttpRequestMessage 
Dim statusCode As HttpStatusCode 
Dim value As T
Dim mediaType As String 
Dim returnValue As HttpResponseMessage 

returnValue = request.CreateResponse(statusCode, _
    value, mediaType)
public static HttpResponseMessage CreateResponse<T>(
    this HttpRequestMessage request,
    HttpStatusCode statusCode,
    T value,
    string mediaType
generic<typename T>
static HttpResponseMessage^ CreateResponse(
    HttpRequestMessage^ request, 
    HttpStatusCode statusCode, 
    T value, 
    String^ mediaType
static member CreateResponse : 
        request:HttpRequestMessage * 
        statusCode:HttpStatusCode * 
        value:'T * 
        mediaType:string -> HttpResponseMessage
JScript does not support generic types and methods.

Type Parameters

  • T
    The type of the HTTP response message.


  • request
    Type: HttpRequestMessage
    The HTTP request message which led to this response message.
  • value
    Type: T
    The content of the HTTP response message.

Return Value

Type: HttpResponseMessage
An initialized HttpResponseMessage wired up to the associated HttpRequestMessage.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type HttpRequestMessage. When you use instance method syntax to call this method, omit the first parameter. For more information, see or

See Also


HttpRequestMessageExtensions Class

CreateResponse Overload

System.Net.Http Namespace