HttpListenerContext Class
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Provides access to the request and response objects used by the HttpListener class. This class cannot be inherited.
Inheritance Hierarchy
System. . :: . .Object
System.Net..::..HttpListenerContext
Namespace: System.Net
Assembly: System.Http (in System.Http.dll)
Syntax
'Declaration
Public Class HttpListenerContext
public class HttpListenerContext
public ref class HttpListenerContext
type HttpListenerContext = class end
public class HttpListenerContext
The HttpListenerContext type exposes the following members.
Properties
Name | Description | |
---|---|---|
Request | Gets the HttpListenerRequest that represents a client's request for a resource. | |
Response | Gets the HttpListenerResponse object that will be sent to the client in response to the client's request. |
Top
Methods
Name | Description | |
---|---|---|
Close() () () () | Closes the stream attached to this listener context. | |
Close(Int32) | Closes the stream attached to this listener context with the specified value for how long the socket should linger after closing. | |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Reset | Clears values for the HttpListenerContext instance. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Remarks
This class provides the information related to a client's Hypertext Transfer Protocol (HTTP) request being processed by an HttpListener object. This class also has methods that allow an HttpListener object to accept a WebSocket connection.
The GetContext method returns instances of the HttpListenerContext class. To get the object that represents the client request, use the Request property. To get the object that represents the response that will be sent to the client by the HttpListener, use the Response property. To get user information about the client sending the request, such as its login name and whether it has been authenticated, you can query the properties in the IPrincipal object returned by the User property.
Closing an HttpListenerContext object sends the response to the client and frees any resources used by the HttpListenerContext. Aborting an HttpListenerContext object discards the response to the client if it has not already been sent, and frees any resources used by the HttpListenerContext. After closing or aborting an HttpListenerContext object, you cannot reference its methods or properties. If you do so, you will receive an ObjectDisposedException exception.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.