IHttpResponseFeature Interface

Represents the fields and state of an HTTP response.

Namespace
Microsoft.AspNetCore.Http.Features
Assemblies
  • Microsoft.AspNetCore.Http.Features

Syntax

public interface IHttpResponseFeature
interface Microsoft.AspNetCore.Http.Features.IHttpResponseFeature

Properties

Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.Body

The System.IO.Stream for writing the response body.

Return type:System.IO.Stream
Stream Body { get; set; }
Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.HasStarted

Indicates if the response has started. If true, the Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.StatusCode, Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.ReasonPhrase, and Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.Headers are now immutable, and OnStarting should no longer be called.

Return type:System.Boolean
bool HasStarted { get; }
Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.Headers

The response headers to send. Headers with multiple values will be emitted as multiple headers.

Return type:Microsoft.AspNetCore.Http.IHeaderDictionary
IHeaderDictionary Headers { get; set; }
Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.ReasonPhrase

The reason-phrase as defined in RFC 7230. Note this field is no longer supported by HTTP/2.

Return type:System.String
string ReasonPhrase { get; set; }
Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.StatusCode

The status-code as defined in RFC 7230. The default value is 200.

Return type:System.Int32
int StatusCode { get; set; }

Methods

OnCompleted(System.Func<System.Object, System.Threading.Tasks.Task>, System.Object)

Registers a callback to be invoked after a response has fully completed. This is intended for resource cleanup.

Arguments:
  • callback (System.Func<System.Object>) – The callback to invoke after the response has completed.
  • state (System.Object) – The state to pass into the callback.
void OnCompleted(Func<object, Task> callback, object state)
OnStarting(System.Func<System.Object, System.Threading.Tasks.Task>, System.Object)

Registers a callback to be invoked just before the response starts. This is the last chance to modify the Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.Headers, Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.StatusCode, or Microsoft.AspNetCore.Http.Features.IHttpResponseFeature.ReasonPhrase.

Arguments:
  • callback (System.Func<System.Object>) – The callback to invoke when starting the response.
  • state (System.Object) – The state to pass into the callback.
void OnStarting(Func<object, Task> callback, object state)