Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

Results.Bytes Method

Definition

Namespace:
Microsoft.AspNetCore.Http
Assembly:
Microsoft.AspNetCore.Http.Results.dll
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.App.Ref v7.0.5
Package:
Microsoft.AspNetCore.App.Ref v8.0.19
Package:
Microsoft.AspNetCore.App.Ref v9.0.8
Package:
Microsoft.AspNetCore.App.Ref v6.0.36

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Name Description
Bytes(ReadOnlyMemory<Byte>, String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Writes the byte-array content to the response.

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

Bytes(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Writes the byte-array content to the response.

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

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

Bytes(ReadOnlyMemory<Byte>, String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Source:
Results.cs

Writes the byte-array content to the response.

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

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

Parameters

contents
ReadOnlyMemory<Byte>

The file contents.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

Returns

The created IResult for the response.

Applies to

Bytes(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)

Source:
Results.cs

Writes the byte-array content to the response.

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

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

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

Parameters

contents
Byte[]

The file contents.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

Returns

The created IResult for the response.

Applies to


Feedback

Was this page helpful?