src/packages/EmbedIO/HttpContextExtensions-Responses.cs
/// <summary>
/// Asynchronously sends a string as response.
/// </summary>
/// <param name="this">The <see cref="IHttpResponse"/> interface on which this method is called.</param>
/// <param name="content">The response content.</param>
/// <param name="contentType">The MIME type of the content. If <see langword="null"/>, the content type will not be set.</param>
/// <param name="encoding">The <see cref="Encoding"/> to use.</param>
/// <returns>A <see cref="Task"/> representing the ongoing operation.</returns>
/// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">
/// <para><paramref name="content"/> is <see langword="null"/>.</para>
/// <para>- or -</para>
/// <para><paramref name="encoding"/> is <see langword="null"/>.</para>
/// </exception>
Asynchronously sends a string as response.
Asynchronously sends a string as response .
public static async Task SendStringAsync(
            this IHttpContext @this,
            string content,
            string contentType,
            Encoding encoding)
        {
            content = Validate.NotNull(nameof(content), content);
            encoding = Validate.NotNull(nameof(encoding), encoding);
            if (contentType != null)
            {
                @this.Response.ContentType = contentType;
                @this.Response.ContentEncoding = encoding;
            }
            using var text = @this.OpenResponseText(encoding);
            await text.WriteAsync(content).ConfigureAwait(false);
        }
public static async Task SendStringAsync ( this IHttpContext @this , string content , string contentType , Encoding encoding ) { content = Validate . NotNull ( nameof ( content ) , content ) ; encoding = Validate . NotNull ( nameof ( encoding ) , encoding ) ; if ( contentType != null ) { @this . Response . ContentType = contentType ; @this . Response . ContentEncoding = encoding ; } using var text = @this . OpenResponseText ( encoding ) ; await text . WriteAsync ( content ) . ConfigureAwait ( false ) ; }
Asynchronously sends a string as response.
Asynchronously sends a string as response .
A  representing the ongoing operation.
A representing the ongoing operation .
None
None
IHttpContext
this
content
string
The response content.
The response content .
contentType
string
The MIME type of the content. If , the content type will not be set.
The MIME type of the content . If the content type will not be set .
encoding
Encoding
The  to use.
The to use .
this
The  interface on which this method is called.
The interface on which this method is called .