Share via


TypedResults.PhysicalFile Method

Definition

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

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 PhysicalFileHttpResult for the response.

Applies to