Skip to content
Trevor Prinn edited this page Sep 1, 2016 · 8 revisions

Babbacombe.Webserver

The Babbacombe Webserver is a small, lean webserver implemented in a dll. It is designed to be included in C# applications that require one or more network interfaces. It works unchanged on Windows and on Linux using Mono.

(It does not work with Xamarin, as that contains no implementation of System.Web, which is used by this project).

The basic server implementation in the dll does not provide any security whatsoever. It is designed to be used within a trusted intranet, or over a VPN, and must not be connected directly to the internet.

Intended uses include:

  • Browser based remote control for an appliance.
  • Desktop application remote control for an appliance.
  • Supplying data from an application on demand across a network.
  • Upload facilities.
  • Download facilities.
  • Implementing REST APIs.

It is not primarily designed for providing database applications although, by using and extending the HttpPage class in particular, it can be used for applications of that sort.

Main facilities

  • Single web application, or multiple web applications on one host (either within one app or multiple apps).
  • Persistent cookie based sessions.
  • Automatic purging of sessions after a timeout.
  • Each request is managed on a separate thread.
  • Automatic provision of files, e.g. html, scripts and files for download.
  • Hooks to allow files, such as pages, to be created or modified before sending.
  • Handling of uploaded files, either directly from posted data or from multipart form data (using streams, so minimal use of memory even with large files).
  • Easy access to query items within an url and to posted data, either through request properties or view models.
  • Automatically routes requests to app provided request handler classes and methods, if the request url's query string provides suitable parameters (useful for managing posted data and ajax requests). This makes it very easy to implement a REST API.
  • Automatic persistence of request handler objects within a session.

There is no intention to add some of the more advanced facilities of MVC to the Webserver, but some MVC like facilities are implemented in it. Request Handlers are essentially the same as MVC's Controller classes, and a simple version of the MVC ModelBinder allows query or posted data items to be copied directly into parameters of the Request Handler methods. There is no equivalent of MVC's cshtml files; instead pages can be constructed, using a View Model if desired, and modified as XML documents before sending to the client.

These facilities are demonstrated within the Sample App provided.

The library is available from the Babbacombe myget (nuget) feed https://www.myget.org/F/babbacom-feed/api/v2