Dela via


Results.File Method

Definition

Overloads

File(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 Bytes(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue).

File(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 Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean).

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

Writes the file at the specified path to the response.

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

File(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 Bytes(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue).

public static Microsoft.AspNetCore.Http.IResult File (byte[] fileContents, string? contentType = default, string? fileDownloadName = default, bool enableRangeProcessing = false, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default);
static member File : byte[] * string * string * bool * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue -> Microsoft.AspNetCore.Http.IResult
Public Shared Function File (fileContents 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

fileContents
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

File(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 Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean).

public static Microsoft.AspNetCore.Http.IResult File (System.IO.Stream fileStream, string? contentType = default, string? fileDownloadName = default, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default, bool enableRangeProcessing = false);
static member File : System.IO.Stream * string * string * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue * bool -> Microsoft.AspNetCore.Http.IResult
Public Shared Function File (fileStream 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

fileStream
Stream

The Stream with the contents of the file.

contentType
String

The Content-Type of the file.

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 fileStream parameter is disposed after the response is sent.

Applies to

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

Source:
Results.cs

Writes the file at the specified path to the response.

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

public static Microsoft.AspNetCore.Http.IResult File (string path, string? contentType = default, string? fileDownloadName = default, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default, bool enableRangeProcessing = false);
static member File : string * string * string * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue * bool -> Microsoft.AspNetCore.Http.IResult
Public Shared Function File (path As String, 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

path
String

The path to the file. When not rooted, resolves the path relative to WebRootFileProvider.

contentType
String

The Content-Type of the file.

fileDownloadName
String

The suggested file name.

lastModified
Nullable<DateTimeOffset>

The DateTimeOffset of when the file was last modified.

entityTag
EntityTagHeaderValue

The EntityTagHeaderValue associated with the file.

enableRangeProcessing
Boolean

Set to true to enable range requests processing.

Returns

The created IResult for the response.

Applies to