HttpListenerContext Class
Provides access to the request and response objects used by the HttpListener class. This class cannot be inherited.
Assembly: System (in System.dll)
The HttpListenerContext type exposes the following members.
| 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. |
![]() | User | Gets an object used to obtain identity, authentication information, and security roles for the client whose request is represented by this HttpListenerContext object. |
| Name | Description | |
|---|---|---|
![]() | 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.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
This class provides the information related to a client's Hypertext Transfer Protocol (HTTP) request being processed by an HttpListener object. 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.
Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: Service pack 2 is required to use the HttpListener class.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
