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

文件的路径。 如果未获取 root 权限,则解析相对于 WebRootFileProvider的路径。

contentType
String

文件的 Content-Type。

fileDownloadName
String

建议的文件名。

lastModified
Nullable<DateTimeOffset>

DateTimeOffset上次修改文件时的 。

entityTag
EntityTagHeaderValue

EntityTagHeaderValue 文件关联的 。

enableRangeProcessing
Boolean

设置为 true 以启用范围请求处理。

返回

为响应创建的 PhysicalFileHttpResult

适用于