HttpListenerResponse Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a response to a request being handled by an HttpListener object.
public ref class HttpListenerResponse sealed : IDisposable
public sealed class HttpListenerResponse : IDisposable
type HttpListenerResponse = class
interface IDisposable
Public NotInheritable Class HttpListenerResponse
Implements IDisposable
- Inheritance
-
HttpListenerResponse
- Implements
When a client makes a request for a resource handled by an HttpListener object, the request and response are made available to your application in an HttpListenerContext object. The request is represented by an HttpListenerRequest object and is available in the HttpListenerContext.Request property. The response is represented by an HttpListenerResponse object and is available in the HttpListenerContext.Response property.
You can customize the response by setting various properties, such as StatusCode, StatusDescription, and Cookies. Use the HttpListenerResponse.OutputStream property to obtain a Stream instance to which response data can be written. Finally, send the response data to the client by calling the Close method.
Content |
Gets or sets the Encoding for this response's OutputStream. |
Content |
Gets or sets the number of bytes in the body data included in the response. |
Content |
Gets or sets the MIME type of the content returned. |
Cookies |
Gets or sets the collection of cookies returned with the response. |
Headers |
Gets or sets the collection of header name/value pairs returned by the server. |
Keep |
Gets or sets a value indicating whether the server requests a persistent connection. |
Output |
Gets a Stream object to which a response can be written. |
Protocol |
Gets or sets the HTTP version used for the response. |
Redirect |
Gets or sets the value of the HTTP |
Send |
Gets or sets whether the response uses chunked transfer encoding. |
Status |
Gets or sets the HTTP status code to be returned to the client. |
Status |
Gets or sets a text description of the HTTP status code returned to the client. |
Abort() |
Closes the connection to the client without sending a response. |
Add |
Adds the specified header and value to the HTTP headers for this response. |
Append |
Adds the specified Cookie to the collection of cookies for this response. |
Append |
Appends a value to the specified HTTP header to be sent with this response. |
Close() |
Sends the response to the client and releases the resources held by this HttpListenerResponse instance. |
Close(Byte[], Boolean) |
Returns the specified byte array to the client and releases the resources held by this HttpListenerResponse instance. |
Copy |
Copies properties from the specified HttpListenerResponse to this response. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
Redirect(String) |
Configures the response to redirect the client to the specified URL. |
Set |
Adds or updates a Cookie in the collection of cookies sent with this response. |
To |
Returns a string that represents the current object. (Inherited from Object) |
IDisposable. |
Releases all resources used by the HttpListenerResponse. |
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.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 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: