Class WebServer
EmbedIO's web server. This is the default implementation of IWebServer.
This class also contains some useful constants related to EmbedIO's internal working.
Implements
Inherited Members
Namespace: EmbedIO
Syntax
public class WebServer : WebServerBase<WebServerOptions>, IWebServer, IDisposable, IWebModuleContainer, IMimeTypeCustomizer, IMimeTypeProvider, IHttpContextHandler
Constructors
WebServer()
Initializes a new instance of the WebServer class, that will respond on HTTP port 80 on all network interfaces.
Declaration
public WebServer()
WebServer(Action<WebServerOptions>)
Initializes a new instance of the WebServer class.
Declaration
public WebServer(Action<WebServerOptions> configure)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<WebServerOptions> | configure | A callback that will be used to configure the server's options. |
WebServer(HttpListenerMode, String[])
Initializes a new instance of the WebServer class.
Declaration
public WebServer(HttpListenerMode mode, params string[] urlPrefixes)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpListenerMode | mode | The type of HTTP listener to configure. |
| String[] | urlPrefixes | The URL prefixes to configure. |
WebServer(HttpListenerMode, X509Certificate2, String[])
Initializes a new instance of the WebServer class.
Declaration
public WebServer(HttpListenerMode mode, X509Certificate2 certificate, params string[] urlPrefixes)
Parameters
| Type | Name | Description |
|---|---|---|
| HttpListenerMode | mode | The type of HTTP listener to configure. |
| X509Certificate2 | certificate | The X.509 certificate to use for SSL connections. |
| String[] | urlPrefixes | The URL prefixes to configure. |
WebServer(WebServerOptions)
Initializes a new instance of the WebServer class.
Declaration
public WebServer(WebServerOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| WebServerOptions | options | A WebServerOptions object used to configure this instance. |
WebServer(Int32)
Initializes a new instance of the WebServer class, that will respond on the specified HTTP port on all network interfaces.
Declaration
public WebServer(int port)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | port | The port. |
WebServer(String[])
Initializes a new instance of the WebServer class with the specified URL prefixes.
Declaration
public WebServer(params string[] urlPrefixes)
Parameters
| Type | Name | Description |
|---|---|---|
| String[] | urlPrefixes | The URL prefixes to configure. |
Fields
Signature
The signature string included in Server response headers.
Declaration
public static readonly string Signature
Field Value
| Type | Description |
|---|---|
| String |
StreamCopyBufferSize
The size, in bytes,of buffers used to transfer contents between streams.
The value of this constant is the same as the default used by the
Declaration
public const int StreamCopyBufferSize = 81920
Field Value
| Type | Description |
|---|---|
| Int32 |
Properties
IsIPv4Supported
Gets whether IPv4 is supported on the machine.
Declaration
public static bool IsIPv4Supported { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
IsIPv6Supported
Gets whether IPv6 is supported on the machine.
Declaration
public static bool IsIPv6Supported { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Listener
Gets the underlying HTTP listener.
Declaration
public IHttpListener Listener { get; }
Property Value
| Type | Description |
|---|---|
| IHttpListener |
Methods
Dispose(Boolean)
Releases unmanaged and - optionally - managed resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | disposing |
|
Overrides
OnFatalException()
Called when an exception is caught in the web server's request processing loop.
This method should tell the server socket to stop accepting further requests.
Declaration
protected override void OnFatalException()
Overrides
Prepare(CancellationToken)
Prepares a web server for running.
Declaration
protected override void Prepare(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | A |
Overrides
ProcessRequestsAsync(CancellationToken)
Asynchronously receives requests and processes them.
Declaration
protected override Task ProcessRequestsAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | A |
Returns
| Type | Description |
|---|---|
| Task | A |