Share via


TypedResults.Content Method

Definition

Overloads

Content(String, MediaTypeHeaderValue)

Writes the content string to the HTTP response.

Content(String, String, Encoding)

Writes the content string to the HTTP response.

This is equivalent to Text(String, String, Encoding).

Content(String, String, Encoding, Nullable<Int32>)

Writes the content string to the HTTP response.

This is equivalent to Text(String, String, Encoding, Nullable<Int32>).

Content(String, MediaTypeHeaderValue)

Writes the content string to the HTTP response.

public static Microsoft.AspNetCore.Http.HttpResults.ContentHttpResult Content (string? content, Microsoft.Net.Http.Headers.MediaTypeHeaderValue contentType);
static member Content : string * Microsoft.Net.Http.Headers.MediaTypeHeaderValue -> Microsoft.AspNetCore.Http.HttpResults.ContentHttpResult
Public Shared Function Content (content As String, contentType As MediaTypeHeaderValue) As ContentHttpResult

Parameters

content
String

The content to write to the response.

contentType
MediaTypeHeaderValue

The content type (MIME type).

Returns

The created ContentHttpResult object for the response.

Applies to

Content(String, String, Encoding)

Writes the content string to the HTTP response.

This is equivalent to Text(String, String, Encoding).

public static Microsoft.AspNetCore.Http.HttpResults.ContentHttpResult Content (string? content, string? contentType, System.Text.Encoding? contentEncoding);
static member Content : string * string * System.Text.Encoding -> Microsoft.AspNetCore.Http.HttpResults.ContentHttpResult
Public Shared Function Content (content As String, contentType As String, contentEncoding As Encoding) As ContentHttpResult

Parameters

content
String

The content to write to the response.

contentType
String

The content type (MIME type).

contentEncoding
Encoding

The content encoding.

Returns

The created ContentHttpResult object for the response.

Remarks

If encoding is provided by both the 'charset' and the contentEncoding parameters, then the contentEncoding parameter is chosen as the final encoding.

Applies to

Content(String, String, Encoding, Nullable<Int32>)

Writes the content string to the HTTP response.

This is equivalent to Text(String, String, Encoding, Nullable<Int32>).

public static Microsoft.AspNetCore.Http.HttpResults.ContentHttpResult Content (string? content, string? contentType = default, System.Text.Encoding? contentEncoding = default, int? statusCode = default);
static member Content : string * string * System.Text.Encoding * Nullable<int> -> Microsoft.AspNetCore.Http.HttpResults.ContentHttpResult
Public Shared Function Content (content As String, Optional contentType As String = Nothing, Optional contentEncoding As Encoding = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As ContentHttpResult

Parameters

content
String

The content to write to the response.

contentType
String

The content type (MIME type).

contentEncoding
Encoding

The content encoding.

statusCode
Nullable<Int32>

The status code to return.

Returns

The created ContentHttpResult object for the response.

Remarks

If encoding is provided by both the 'charset' and the contentEncoding parameters, then the contentEncoding parameter is chosen as the final encoding.

Applies to