Results.Stream 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
Stream(Func<Stream,Task>, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue)
允許直接寫入回應本文。
這支援範圍要求 (Status206PartialContent ,或者 Status416RangeNotSatisfiable 範圍無法滿足) 。
public static Microsoft.AspNetCore.Http.IResult Stream (Func<System.IO.Stream,System.Threading.Tasks.Task> streamWriterCallback, string? contentType = default, string? fileDownloadName = default, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default);
static member Stream : Func<System.IO.Stream, System.Threading.Tasks.Task> * string * string * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Stream (streamWriterCallback As Func(Of Stream, Task), Optional contentType As String = Nothing, Optional fileDownloadName As String = Nothing, Optional lastModified As Nullable(Of DateTimeOffset) = Nothing, Optional entityTag As EntityTagHeaderValue = Nothing) As IResult
參數
- contentType
- String
回應的 Content-Type
。 預設值為 application/octet-stream
。
- fileDownloadName
- String
要用於標頭的 Content-Disposition
檔案名。
- lastModified
- Nullable<DateTimeOffset>
DateTimeOffset上次修改檔案時的 。
用來設定 Last-Modified
回應標頭並執行條件式範圍要求。
- entityTag
- EntityTagHeaderValue
EntityTagHeaderValue要設定 ETag
回應標頭並執行條件式要求的 。
傳回
為回應建立 IResult 的 。
適用於
Stream(PipeReader, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)
將指定 PipeReader 的內容寫入回應。
這支援範圍要求 (Status206PartialContent ,或者 Status416RangeNotSatisfiable 範圍無法滿足) 。
public static Microsoft.AspNetCore.Http.IResult Stream (System.IO.Pipelines.PipeReader pipeReader, string? contentType = default, string? fileDownloadName = default, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default, bool enableRangeProcessing = false);
static member Stream : System.IO.Pipelines.PipeReader * string * string * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue * bool -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Stream (pipeReader As PipeReader, 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
參數
- pipeReader
- PipeReader
PipeReader要寫入回應的 。
- contentType
- String
回應的 Content-Type
。 預設值為 application/octet-stream
。
- fileDownloadName
- String
要用於標頭的 Content-Disposition
檔案名。
- lastModified
- Nullable<DateTimeOffset>
DateTimeOffset上次修改檔案時的 。
用來設定 Last-Modified
回應標頭並執行條件式範圍要求。
- entityTag
- EntityTagHeaderValue
EntityTagHeaderValue要設定 ETag
回應標頭並執行條件式要求的 。
- enableRangeProcessing
- Boolean
設定為 true
以啟用範圍要求處理。
傳回
為回應建立 IResult 的 。
備註
在傳送回應之後,參數 pipeReader
就會完成。
適用於
Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)
將指定的 Stream 寫入回應。
這支援範圍要求 (Status206PartialContent ,或者 Status416RangeNotSatisfiable 範圍無法滿足) 。
此 API 是 的 File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean) 別名。
public static Microsoft.AspNetCore.Http.IResult Stream (System.IO.Stream stream, string? contentType = default, string? fileDownloadName = default, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default, bool enableRangeProcessing = false);
static member Stream : System.IO.Stream * string * string * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue * bool -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Stream (stream 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
參數
- contentType
- String
回應的 Content-Type
。 預設值為 application/octet-stream
。
- fileDownloadName
- String
要用於標頭的 Content-Disposition
檔案名。
- lastModified
- Nullable<DateTimeOffset>
DateTimeOffset上次修改檔案時的 。
用來設定 Last-Modified
回應標頭並執行條件式範圍要求。
- entityTag
- EntityTagHeaderValue
EntityTagHeaderValue要設定 ETag
回應標頭並執行條件式要求的 。
- enableRangeProcessing
- Boolean
設定為 true
以啟用範圍要求處理。
傳回
為回應建立 IResult 的 。
備註
在傳送回應之後,會 stream
處置 參數。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應