[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Provides a simple, programmatically controlled HTTP protocol listener. This class cannot be inherited.
Assembly: System.Http (in System.Http.dll)
Thetype exposes the following members.
|Abort||Shuts down the object immediately, discarding all currently queued requests.|
|Close||Shuts down the .|
|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.)|
|GetContext||Waits for an incoming request and returns when one is received.|
|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.)|
|Start||Allows this instance to receive incoming requests.|
|Stop||Causes this instance to stop receiving incoming requests.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
Using the class, you can create a simple HTTP protocol listener that responds to HTTP requests. The listener is active for the lifetime of the object and runs within your application with its permissions.
To use , create a new instance of the class using the constructor and use the property to gain access to the collection that holds the strings that specify which Uniform Resource Identifier (URI) prefixes the should process.
A URI prefix string is composed of a scheme (http or https), a host, an optional port, and an optional path. An example of a complete prefix string is "http://www.contoso.com:8080/customerData/". Prefixes must end in a forward slash ("/"). The object with the prefix that most closely matches a requested URI responds to the request.
When a port is specified, the host element can be replaced with "*" to indicate that the accepts requests sent to the port if the requested URI does not match any other prefix. For example, to receive all requests sent to port 8080 when the requested URI is not handled by any , the prefix is "http://*:8080/". Similarly, to specify that the accepts all requests sent to a port, replace the host element with the "+" character, "https://+:8080". The "*" and "+" characters can be present in prefixes that include paths.
To begin listening for requests from clients, add the URI prefixes to the collection and call the Start method.
The synchronous model is appropriate if your application should block while waiting for a client request and if you want to process only one request at a time. Using the synchronous model, call the GetContext method, which waits for a client to send a request. The method returns an HttpListenerContext object to you for processing when one occurs.