TypedResults.PhysicalFile 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将指定 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 。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈