HttpRequestMessageExtensions.CreateResponse<T> Method (, HttpStatusCode, T, MediaTypeFormatter, String)
Creates an HttpResponseMessage wired up to the associated HttpRequestMessage.
Namespace: System.Net.Http
Assembly: System.Web.Http (in System.Web.Http.dll)
Syntax
'Declaration
<ExtensionAttribute> _
Public Shared Function CreateResponse(Of T) ( _
request As HttpRequestMessage, _
statusCode As HttpStatusCode, _
value As T, _
formatter As MediaTypeFormatter, _
mediaType As String _
) As HttpResponseMessage
'Usage
Dim request As HttpRequestMessage
Dim statusCode As HttpStatusCode
Dim value As T
Dim formatter As MediaTypeFormatter
Dim mediaType As String
Dim returnValue As HttpResponseMessage
returnValue = request.CreateResponse(statusCode, _
value, formatter, mediaType)
public static HttpResponseMessage CreateResponse<T>(
this HttpRequestMessage request,
HttpStatusCode statusCode,
T value,
MediaTypeFormatter formatter,
string mediaType
)
[ExtensionAttribute]
public:
generic<typename T>
static HttpResponseMessage^ CreateResponse(
HttpRequestMessage^ request,
HttpStatusCode statusCode,
T value,
MediaTypeFormatter^ formatter,
String^ mediaType
)
static member CreateResponse :
request:HttpRequestMessage *
statusCode:HttpStatusCode *
value:'T *
formatter:MediaTypeFormatter *
mediaType:string -> HttpResponseMessage
JScript does not support generic types and methods.
Type Parameters
- T
The type of the HTTP response message.
Parameters
request
Type: HttpRequestMessageThe HTTP request message which led to this response message.
statusCode
Type: System.Net.HttpStatusCodeThe HTTP response status code.
value
Type: TThe content of the HTTP response message.
formatter
Type: System.Net.Http.Formatting.MediaTypeFormatterThe media type formatter.
mediaType
Type: System.StringThe media type.
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 https://msdn.microsoft.com/en-us/library/bb384936(v=vs.108) or https://msdn.microsoft.com/en-us/library/bb383977(v=vs.108).