HttpListenerResponse 類別
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示 HttpListener 物件所處理之要求的回應。
public ref class HttpListenerResponse sealed : IDisposable
public sealed class HttpListenerResponse : IDisposable
type HttpListenerResponse = class
interface IDisposable
Public NotInheritable Class HttpListenerResponse
Implements IDisposable
- 繼承
-
HttpListenerResponse
- 實作
當客戶端對對象所處理 HttpListener 的資源提出要求時,會將要求和回應提供給物件中的 HttpListenerContext 應用程式使用。 要求是以 HttpListenerRequest 物件表示,而且可在屬性中使用 HttpListenerContext.Request 。 回應是以 HttpListenerResponse 物件表示, HttpListenerContext.Response 而且可在屬性中使用。
您可以藉由設定各種屬性來自定義回應,例如 StatusCode、 StatusDescription和 Cookies。 HttpListenerResponse.OutputStream使用屬性來取得Stream可寫入回應數據的實例。 最後,呼叫 Close 方法,將響應數據傳送至用戶端。
Content |
取得或設定這個回應之 Encoding 的 OutputStream。 |
Content |
取得或設定回應中所包含之主體資料的位元組數。 |
Content |
取得或設定傳回內容的 MIME 類型。 |
Cookies |
取得或設定隨回應所傳回之 Cookie 的集合。 |
Headers |
取得或設定伺服器所傳回之標頭名稱/值組的集合。 |
Keep |
取得或設定值,指出伺服器是否要求持續性連線。 |
Output |
取得可寫入回應的 Stream 物件。 |
Protocol |
取得或設定用於回應的 HTTP 版本。 |
Redirect |
取得或設定在這個回應中 HTTP |
Send |
取得或設定值,指出回應是否使用區塊傳輸編碼方式。 |
Status |
取得或設定傳回至用戶端的 HTTP 狀態碼。 |
Status |
取得或設定傳回至用戶端之 HTTP 狀態碼的文字描述。 |
Abort() |
關閉與用戶端的連線,而不傳送回應。 |
Add |
將指定的標頭和值加入至這個回應的 HTTP 標頭。 |
Append |
針對這個回應,將指定的 Cookie 加入至 Cookie 的集合。 |
Append |
附加值至指定的 HTTP 標頭,隨這個回應傳送。 |
Close() |
將回應傳送至用戶端,並釋放這個 HttpListenerResponse 執行個體所持有的資源。 |
Close(Byte[], Boolean) |
將指定的位元組陣列傳回至用戶端,並釋放這個 HttpListenerResponse 執行個體所持有的資源。 |
Copy |
從指定的 HttpListenerResponse 複製屬性至這個回應。 |
Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
Get |
做為預設雜湊函式。 (繼承來源 Object) |
Get |
取得目前執行個體的 Type。 (繼承來源 Object) |
Memberwise |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
Redirect(String) |
將回應設定為重新導向用戶端至指定的 URL。 |
Set |
隨這個回應傳送的 Cookie 集合中,加入或更新 Cookie。 |
To |
傳回代表目前物件的字串。 (繼承來源 Object) |
IDisposable. |
釋放 HttpListenerResponse 所使用的所有資源。 |
產品 | 版本 |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |