Share via


TypedResults.PhysicalFile 方法

定義

將指定 path 位置的 檔案寫入回應。

這支援範圍要求 (Status206PartialContent ,或 Status416RangeNotSatisfiable 範圍不符合) 。

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

參數

path
String

檔案的路徑。 未進行根目錄時,會解析相對於 WebRootFileProvider 的路徑。

contentType
String

檔案的內容類型。

fileDownloadName
String

建議的檔案名。

lastModified
Nullable<DateTimeOffset>

DateTimeOffset上次修改檔案時的 。

entityTag
EntityTagHeaderValue

EntityTagHeaderValue 檔案相關聯的 。

enableRangeProcessing
Boolean

設定為 true 以啟用範圍要求處理。

傳回

為回應建立 PhysicalFileHttpResult 的 。

適用於