Unosquare
    Show / Hide Table of Contents

    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.

    Inheritance
    Object
    WebServerBase<WebServerOptions>
    WebServer
    Implements
    IWebServer
    IDisposable
    IWebModuleContainer
    IMimeTypeCustomizer
    IMimeTypeProvider
    IHttpContextHandler
    Inherited Members
    WebServerBase<WebServerOptions>.StateChanged
    WebServerBase<WebServerOptions>.Modules
    WebServerBase<WebServerOptions>.SharedItems
    WebServerBase<WebServerOptions>.Options
    WebServerBase<WebServerOptions>.OnUnhandledException
    WebServerBase<WebServerOptions>.OnHttpException
    WebServerBase<WebServerOptions>.SessionManager
    WebServerBase<WebServerOptions>.State
    WebServerBase<WebServerOptions>.LogSource
    WebServerBase<WebServerOptions>.HandleContextAsync(IHttpContextImpl)
    WebServerBase<WebServerOptions>.GetMimeType(String)
    WebServerBase<WebServerOptions>.TryDetermineCompression(String, Boolean)
    WebServerBase<WebServerOptions>.AddCustomMimeType(String, String)
    WebServerBase<WebServerOptions>.PreferCompression(String, Boolean)
    WebServerBase<WebServerOptions>.RunAsync(CancellationToken)
    WebServerBase<WebServerOptions>.Dispose()
    WebServerBase<WebServerOptions>.DoHandleContextAsync(IHttpContextImpl)
    WebServerBase<WebServerOptions>.OnBeforeLockConfiguration()
    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 method. For the reasons why this value was chosen, see .NET Framework reference source.

    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

    true to release both managed and unmanaged resources; false to release only unmanaged resources.

    Overrides
    EmbedIO.WebServerBase<EmbedIO.WebServerOptions>.Dispose(System.Boolean)

    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
    EmbedIO.WebServerBase<EmbedIO.WebServerOptions>.OnFatalException()

    Prepare(CancellationToken)

    Prepares a web server for running.

    Declaration
    protected override void Prepare(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A used to stop the web server.

    Overrides
    EmbedIO.WebServerBase<EmbedIO.WebServerOptions>.Prepare(CancellationToken)

    ProcessRequestsAsync(CancellationToken)

    Asynchronously receives requests and processes them.

    Declaration
    protected override Task ProcessRequestsAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A used to stop the web server.

    Returns
    Type Description
    Task

    A representing the ongoing operation.

    Overrides
    EmbedIO.WebServerBase<EmbedIO.WebServerOptions>.ProcessRequestsAsync(CancellationToken)

    Implements

    IWebServer
    IDisposable
    IWebModuleContainer
    IMimeTypeCustomizer
    IMimeTypeProvider
    IHttpContextHandler

    Comments

    Back to top Copyright © 2017-2019 Unosquare