Skip to main content

IResponse

A thin wrapper around each host's Response e.g: ASP.NET, HttpListener, MQ, etc

Assembly: ServiceStack.Interfaces.dll
View Source
Declaration
public interface IResponse

Properties

OriginalResponse

The underlying ASP.NET, .NET Core or HttpListener HttpResponse

View Source
Declaration
object OriginalResponse { get; }

Request

The corresponding IRequest API for this Response

View Source
Declaration
IRequest Request { get; }

StatusCode

The Response Status Code

View Source
Declaration
int StatusCode { get; set; }

StatusDescription

The Response Status Description

View Source
Declaration
string StatusDescription { get; set; }

ContentType

The Content-Type for this Response

View Source
Declaration
string ContentType { get; set; }

OutputStream

The Response Body Output Stream

View Source
Declaration
Stream OutputStream { get; }

Dto

The Response DTO

View Source
Declaration
object Dto { get; set; }

UseBufferedStream

Buffer the Response OutputStream so it can be written in 1 batch

View Source
Declaration
bool UseBufferedStream { get; set; }

IsClosed

Gets a value indicating whether this instance is closed.

View Source
Declaration
bool IsClosed { get; }

KeepAlive

Whether the underlying TCP Connection for this Response should remain open

View Source
Declaration
bool KeepAlive { get; set; }

HasStarted

Whether the HTTP Response Headers have already been written.

View Source
Declaration
bool HasStarted { get; }

Items

View Source
Declaration
Dictionary<string, object> Items { get; }

Methods

AddHeader(String, String)

Add a Header to this Response

View Source
Declaration
void AddHeader(string name, string value)
Parameters
TypeName
System.Stringname
System.Stringvalue

RemoveHeader(String)

Remove an existing Header added on this Response

View Source
Declaration
void RemoveHeader(string name)
Parameters
TypeName
System.Stringname

GetHeader(String)

Get an existing Header added to this Response

View Source
Declaration
string GetHeader(string name)
Returns

System.String

Parameters
TypeName
System.Stringname

Redirect(String)

Return a Redirect Response to the URL specified

View Source
Declaration
void Redirect(string url)
Parameters
TypeName
System.Stringurl

Close()

Signal that this response has been handled and no more processing should be done. When used in a request or response filter, no more filters or processing is done on this request.

View Source
Declaration
void Close()

CloseAsync(CancellationToken)

Close this Response Output Stream Async

View Source
Declaration
Task CloseAsync(CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task

Parameters
TypeName
System.Threading.CancellationTokentoken

End()

Calls Response.End() on ASP.NET HttpResponse otherwise is an alias for Close(). Useful when you want to prevent ASP.NET to provide it's own custom error page.

View Source
Declaration
void End()

Flush()

Response.Flush() and OutputStream.Flush() seem to have different behaviour in ASP.NET

View Source
Declaration
void Flush()

FlushAsync(CancellationToken)

Flush this Response Output Stream Async

View Source
Declaration
Task FlushAsync(CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task

Parameters
TypeName
System.Threading.CancellationTokentoken

SetContentLength(Int64)

Set the Content Length in Bytes for this Response

View Source
Declaration
void SetContentLength(long contentLength)
Parameters
TypeName
System.Int64contentLength