Share via


Results.Stream Method

Definition

Overloads

Stream(Func<Stream,Task>, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Allows writing directly to the response body.

Stream(PipeReader, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Writes the contents of specified PipeReader to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Writes the specified Stream to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

This API is an alias for File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean).

Stream(Func<Stream,Task>, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Source:
Results.cs

Allows writing directly to the response body.

public static Microsoft.AspNetCore.Http.IResult Stream (Func<System.IO.Stream,System.Threading.Tasks.Task> streamWriterCallback, string? contentType = default, string? fileDownloadName = default, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default);
static member Stream : Func<System.IO.Stream, System.Threading.Tasks.Task> * string * string * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Stream (streamWriterCallback As Func(Of Stream, Task), Optional contentType As String = Nothing, Optional fileDownloadName As String = Nothing, Optional lastModified As Nullable(Of DateTimeOffset) = Nothing, Optional entityTag As EntityTagHeaderValue = Nothing) As IResult

Parameters

streamWriterCallback
Func<Stream,Task>

The callback that allows users to write directly to the response body.

contentType
String

The Content-Type of the response. Defaults to application/octet-stream.

fileDownloadName
String

The file name to be used in the Content-Disposition header.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified. Used to configure the Last-Modified response header and perform conditional range requests.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue to be configure the ETag response header and perform conditional requests.

Returns

The created IResult for the response.

Applies to

Stream(PipeReader, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Source:
Results.cs

Writes the contents of specified PipeReader to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

public static Microsoft.AspNetCore.Http.IResult Stream (System.IO.Pipelines.PipeReader pipeReader, string? contentType = default, string? fileDownloadName = default, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default, bool enableRangeProcessing = false);
static member Stream : System.IO.Pipelines.PipeReader * string * string * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue * bool -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Stream (pipeReader As PipeReader, Optional contentType As String = Nothing, Optional fileDownloadName As String = Nothing, Optional lastModified As Nullable(Of DateTimeOffset) = Nothing, Optional entityTag As EntityTagHeaderValue = Nothing, Optional enableRangeProcessing As Boolean = false) As IResult

Parameters

pipeReader
PipeReader

The PipeReader to write to the response.

contentType
String

The Content-Type of the response. Defaults to application/octet-stream.

fileDownloadName
String

The file name to be used in the Content-Disposition header.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified. Used to configure the Last-Modified response header and perform conditional range requests.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue to be configure the ETag response header and perform conditional requests.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created IResult for the response.

Remarks

The pipeReader parameter is completed after the response is sent.

Applies to

Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

Source:
Results.cs

Writes the specified Stream to the response.

This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).

This API is an alias for File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean).

public static Microsoft.AspNetCore.Http.IResult Stream (System.IO.Stream stream, string? contentType = default, string? fileDownloadName = default, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default, bool enableRangeProcessing = false);
static member Stream : System.IO.Stream * string * string * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue * bool -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Stream (stream As Stream, Optional contentType As String = Nothing, Optional fileDownloadName As String = Nothing, Optional lastModified As Nullable(Of DateTimeOffset) = Nothing, Optional entityTag As EntityTagHeaderValue = Nothing, Optional enableRangeProcessing As Boolean = false) As IResult

Parameters

stream
Stream

The Stream to write to the response.

contentType
String

The Content-Type of the response. Defaults to application/octet-stream.

fileDownloadName
String

The file name to be used in the Content-Disposition header.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified. Used to configure the Last-Modified response header and perform conditional range requests.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue to be configure the ETag response header and perform conditional requests.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created IResult for the response.

Remarks

The stream parameter is disposed after the response is sent.

Applies to