Interface IWebServer
Represents a web server.
The basic usage of a web server is as follows:
- add modules to the Modules collection;
- set a SessionManager if needed;
- call RunAsync(CancellationToken) to respond to incoming requests.
Inherited Members
Namespace: EmbedIO
Syntax
public interface IWebServer : IDisposable, IWebModuleContainer, IMimeTypeCustomizer, IMimeTypeProvider
Properties
OnHttpException
Gets or sets a callback that is called every time a HTTP exception is thrown during the processing of a request.
This property can never be null.
Declaration
HttpExceptionHandlerCallback OnHttpException { get; set; }
Property Value
Type | Description |
---|---|
HttpExceptionHandlerCallback |
See Also
OnUnhandledException
Gets or sets a callback that is called every time an unhandled exception occurs during the processing of a request.
This property can never be null. If it is still
Declaration
ExceptionHandlerCallback OnUnhandledException { get; set; }
Property Value
Type | Description |
---|---|
ExceptionHandlerCallback |
See Also
SessionManager
Gets or sets the registered session ID manager, if any.
A session ID manager is an implementation of
Note that this property can only be set before starting the web server.
Declaration
ISessionManager? SessionManager { get; set; }
Property Value
Type | Description |
---|---|
Nullable<ISessionManager> | The session manager, or null if no session manager is present. |
State
Gets the state of the web server.
Declaration
WebServerState State { get; }
Property Value
Type | Description |
---|---|
WebServerState | The state. |
See Also
Methods
RunAsync(CancellationToken)
Starts the listener and the registered modules.
Declaration
Task RunAsync(CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The cancellation token; when cancelled, the server cancels all pending requests and stops. |
Returns
Type | Description |
---|---|
Task | Returns the task that the HTTP listener is running inside of, so that it can be waited upon after it's been canceled. |
Events
StateChanged
Occurs when the State property changes.
Declaration
event EventHandler<WebServerStateChangedEventArgs> StateChanged
Event Type
Type | Description |
---|---|
EventHandler<WebServerStateChangedEventArgs> |