Compact Web Server
The mobile web server

About

Compact Web Server is a web server for mobile devices. It works on all devices that are running Windows CE 5.0 or above (for example: Windows Mobile 5.0). The tool allows to share static web sites (for example .html, .htm) or dynamic web sites (.aspc: Active Server Pages Compact).

Active Server Pages Compact is only an extension (so called IPageContentProvider) that plugs into the Compact Web Server. It's possible to write own extensions, to provide data dynamically (the data has not to be as a file on the disc) by loading it from a database or any other data source. Everything that's possible with the .NET compact framework works.

 

How to use the web server

General

You can do the following to set up the web server:

Copy all files and sub directories in the ZIP's "Compiled" directory to your mobile device
OR
configure the web server: The downloaded package contains a config.xml file that contains the whole configuration of the web server. Please customize this file to configure the application.

Afterwards start the cwebsvr.exe to start the web server's UI.

Developer

Add a reference to svr.dll to your own project. Create an instance of the Chili.Sputnik.Server.Settings class and set the required settings. You can set the bound IP addresses, port, error code pages, default documents, restricted paths, page content provider, ... here. This settings class is then given an instance of the Chili.Sputnik.Server.WebServer class. Example:

// Set up the minimal server.
Settings settings = new Settings(IPAddress.Any, 80);
settings.RootDirectory = "webroot\\";

// Create the web server.
WebServer server = new WebServer(settings);
// Start it.
server.Start();

You may also create multiple instances of the web server in your application. For all paths specified in the settings you may also use relative paths!

 

Active Server Pages Compact

This extension allows you to create dynamic pages. The server comes with a picture gallery sample that has been written by using ASPC. Please have a look at the sample to see how ASPC works. You should also try to add new features to the picture gallery to understand how all components work together.

Each .aspc page has a line that specifies a reference to the assembly and class that holds the code for the page! It looks similar to this:

<% CodebehindType="Gallery.GalleryPage, gallery, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" %>

In this case the gallery.dll is loaded. Afterwards the ASPC engine searches for a Gallery.GalleryPage class in that assembly. The class must inherit from the Chili.Sputnik.AspCompact.Page class. The assembly with the code behind must be located in the same directory as the svr.dll. This is required because the .NET framework searches that directory when trying to load a late bound type.

In ASPC the current session, the current request and the current response can be accessed directly. ASPC offers also a view state, like ASP.NET does. Please don't try to put to much data in the session object and/or view state. Keep in mind that most mobile devices have little memory. I did a few tricks, like storing the session to the disc, to keep the memory usage low. But if the page requests a large object from the session it must be loaded into memory! That could lead into a OutOfMemoryException!

ASPC allows you also to use custom controls. I have written a few as examples. They are found in the Chili.Sputnik.AspCompact.Controls namespace. They could be used as templates for other custom controls. Please keep always memory in mind! Try to dispose objects as soon as the aren't use anymore.

<aspc:ControlType="Label" CssClass="timeLabel" ID="timeLabel" />

This is an example of a custom control in an .aspc file. Each custom control needs to have a unique ID and needs to start with <aspc:ControlType="...". The ControlType is a reference to the class that represents the custom control. If no namespace is provides ASPC searches the Chili.Sputnik.AspCompact.Controls namespace for the control class.

The CssClass property in this example represents a property of the Label control. ASPC sets the value specifies in the .aspc file automatically to the instance of the control. You might also specify an attribute that is not mapped directly to a property. For example style="font-size: 8pt;". ASPC detects it as not being mapped to a property and routes it to the final output of the control.

To use the control in the code behind class you need to get it by using the GetControlByID<T>(string id) method of the page. This method returns an instance of the control with the given ID. Example:

LinkButton button = this.GetControlByID<LinkButton>("backButton");

 

Download

To download the Compact Web Server you need to buy a personal license or a commercial license. The download link is provided in the e-mail that is sent as confirmation of the purchase (in the license key section of the mail).

Personal License
Limited to personal use. You are not allowed to use the compact web server (or parts of it) in or as part of any other commercial product.
$ 29.99 Buy now
Premium License
Allows commercial usage of the product. The product (or parts of it) may be used in other commercial products without limitations.
$ 999.00 Buy now

You might also need the .NET compact framework. It needs to be installed on the mobile device. Please download that package here.
To create own .aspc pages you need the SDK for smart phones. Please download that here.

 

Contact and feedback

For any other questions and feedback, please write me also an e-mail.

christian@liensberger.it