Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class Microsoft.​AspNetCore.​Http.​HttpResponse

Assembly: Microsoft.AspNetCore.Http.Abstractions

Inheritance: object → HttpResponse

Represents the outgoing side of an individual HTTP request.

Properties

public HttpContext
HttpContext
Gets the <see cref="P:Microsoft.AspNetCore.Http.HttpResponse.HttpContext" /> for this response.
public int
StatusCode
Gets or sets the HTTP response code.
Headers
Gets the response headers.
Gets or sets the response body <see cref="T:System.IO.Stream" /> .
Gets the response body <see cref="T:System.IO.Pipelines.PipeWriter" />
public long?
ContentLength
Gets or sets the value for the <c>Content-Length</c> response header.
public string
ContentType
Gets or sets the value for the <c>Content-Type</c> response header.
Cookies
Gets an object that can be used to manage cookies for this response.
public bool
HasStarted
Gets a value indicating whether response headers have been sent to the client.

Methods

public void
OnStarting​(System.​Func<​object, System.​Threading.​Tasks.​Task> callback, object state)
Adds a delegate to be invoked just before response headers will be sent to the client. Callbacks registered here run in reverse order.
callback The delegate to execute.
state A state object to capture and pass back to the delegate.
Remarks Callbacks registered here run in reverse order. The last one registered is invoked first. The reverse order is done to replicate the way middleware works, with the inner-most middleware looking at the response first.
public void
OnStarting​(System.​Func<​System.​Threading.​Tasks.​Task> callback)
Adds a delegate to be invoked just before response headers will be sent to the client. Callbacks registered here run in reverse order.
callback The delegate to execute.
Remarks Callbacks registered here run in reverse order. The last one registered is invoked first. The reverse order is done to replicate the way middleware works, with the inner-most middleware looking at the response first.
public void
OnCompleted​(System.​Func<​object, System.​Threading.​Tasks.​Task> callback, object state)
Adds a delegate to be invoked after the response has finished being sent to the client.
callback The delegate to invoke.
state A state object to capture and pass back to the delegate.
public void
RegisterForDispose​(System.​IDisposable disposable)
Registers an object for disposal by the host once the request has finished processing.
disposable The object to be disposed.
public void
RegisterForDisposeAsync​(System.​IAsyncDisposable disposable)
Registers an object for asynchronous disposal by the host once the request has finished processing.
disposable The object to be disposed asynchronously.
public void
OnCompleted​(System.​Func<​System.​Threading.​Tasks.​Task> callback)
Adds a delegate to be invoked after the response has finished being sent to the client.
callback The delegate to invoke.
public void
Redirect​(string location)
Returns a temporary redirect response (HTTP 302) to the client.
location The URL to redirect the client to. This must be properly encoded for use in http headers where only ASCII characters are allowed.
public void
Redirect​(string location, bool permanent)
Returns a redirect response (HTTP 301 or HTTP 302) to the client.
location The URL to redirect the client to. This must be properly encoded for use in http headers where only ASCII characters are allowed.
permanent <c>True</c> if the redirect is permanent (301), otherwise <c>false</c> (302).
StartAsync​(System.​Threading.​CancellationToken cancellationToken = null)
Starts the response by calling OnStarting() and making headers unmodifiable.
CompleteAsync​()
Flush any remaining response headers, data, or trailers. This may throw if the response is in an invalid state such as a Content-Length mismatch.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object