Click here to Skip to main content
11,921,792 members (67,340 online)
Click here to Skip to main content
Add your own
alternative version


41 bookmarked

Using InsomniaServer to Build a Web-interface for your Application

, 15 Jul 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
InsomniaServer enables you to add a fully-featured, customizable webserver to your projects. See how it works.


I always wanted my programs to be controlled over the Internet or a LAN. Indeed, the .NET Framework includes many features to help you achieve this; but I needed more, so I decided to start from the very beginning and created my own, different HTTP server.

Talking about an HTTP server, usually an application sending local files to clients, comes to one's mind. But InsomniaServer is different. It is all about customizing. You are absolutely free to answer every request your very own way, without having to use ASP.NET on IIS or some scripting language on Apache, which are quite big and often inconvenient for special tasks.

Let's pick up my first sentence: You wrote a program, which needs a Web interface. Do you really want to learn all about HTTP to do so? No, you need an easy way, to achieve everything you want - fast, transparent and stable. InsomniaServer is perfect for you.
Another thing: You created a .NET assembly, that does a special (for example mathematical) thing, and want to present its output/reaction on some input on the Internet. Just reference InsomniaServer and you are nearly done.

It would be possible to talk for hours about special cases, in which InsomniaServer is great. Even though it is much better to think about your project and its special scenario, maybe you are looking for something like IS - so I would like to invite you to test it.

Using the Code

Initially I tried to insert the tutorials, I have written for InsomniaServer, here - but had to see that they are a little too long for one article, and I did not want to scare you. So I do (for now) not post them as articles on The CodeProject, but provide them together with my demo projects included within the documentation, which can be downloaded here.

I recommend testing the MultiPaint sample first (best, server and HTTP browser on different machines), as it shows what InsomniaServer is all about. Afterwards, read the tutorials and play with the code, as this is in my opinion the best way to get into a new "technique".

The full documentation of InsomniaServer can be found here.

Points of Interest

While looking at InsomniaServer or developing some program using it (<- I would be pleased to hear about something like thatSmile | :) ), please do not miss the InsomniaSoftware.Server.Debug namespace. I really liked it while debugging and tuning the Web interface of my software.


  • 02/04/07 - Version 1.0 completed

  • 17/04/07 - Small bugfix in HttpRequest.cs (thanks to Alberto aka rwtrecasd)

  • 04/05/07 - InsomniaServer version uploaded

    • Major fixes in HTML-form handling and encoding
    • New functions added
    • Added SystemBrowser sample for those who doubt IS's practical use;). It allows you to view a PC's hardware and disk content via webbrowser (including login and user management).
      This is how SystemBrowser works:

      Screenshot - SystemBrowser_diagram.gif

  • 12/05/07 - InsomniaServer version uploaded

    • HtmlSource added. It enables you to create a structure of HTML elements (many pre-defined and any customized one that you want) - IS builds the final page for you. Just to give a simple example:

      HtmlSource page = new HtmlSource("Hello!");
          ("Hello world! Sp€c?a£ cHäRa?t?r?"));

      This results in:

      <b>Hello world! Sp&#8364;c&#1111;&#261;&#163; 
  • 10/01/08 - InsomniaServer version uploaded

    • Added IPv6 support to IS, which fixed problems with Windows Vista
    • Minor changes
    • Updated examples

Please update to You will have to make no changes within your code.


  • HTTP: The Definitive Guide 1st edition by David Gourley and Brian Totty


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Manuel Then
Germany Germany
I was born in 1987. Unfortunately too late to experience the real rise of the PC. But fortunately late enough to enjoy things like MS's .net during my school time Wink | ;)

From the time when some relative taught me a little BASIC under MS DOS, I loved to tell computers what to do - even though my real start in programming was around the age of 16.

At the moment, I am studying Software Engineering at University of Augsburg, always hoping to find time to design and program.
Besides, I like meeting friends, spent time with my girlfriend and enjoy life Smile | :)

You may also be interested in...

Comments and Discussions

SuggestionIS Use Cse Scenario... Pin
TheRaven18-Jul-11 14:51
memberTheRaven18-Jul-11 14:51 
Questionold source ? Pin
HamsterTrainer0113-Jul-11 11:56
memberHamsterTrainer0113-Jul-11 11:56 
AnswerRe: old source ? Pin
Manuel Then14-Jul-11 11:12
memberManuel Then14-Jul-11 11:12 
GeneralRe: old source ? Pin
HamsterTrainer0114-Jul-11 12:24
memberHamsterTrainer0114-Jul-11 12:24 
GeneralRe: old source ? Pin
Manuel Then15-Jul-11 2:38
memberManuel Then15-Jul-11 2:38 
GeneralQuestion about performance Pin
Dr. Emmett Brown28-Jul-10 15:20
memberDr. Emmett Brown28-Jul-10 15:20 
GeneralRe: Question about performance Pin
Manuel Then4-Aug-10 6:28
memberManuel Then4-Aug-10 6:28 
Hi Emmett,

Thank you for your comment Smile | :)

So your project will mainly be server-based and will have a high throughput? If so, then IS is maybe not optimal for your use case as it is intended to give "client machines" HTTP server capabilities. Consequently, the current implementation is not extremely optimized for performance (though I intend to create IS2 with the main goal performance once I find some time).

However, it is very easy to try IS - so just implement a little logic and profile the system. Some time ago I did this for a simple file server use case and was able to easily serve 100s of files per second (running the program on my notebook) Smile | :)

If you give IS a try, please let me know as I would love feedback on not only the performance but also the interfaces.

GeneralMy vote of 5 Pin
Olivier DANIEL28-Jun-10 6:02
memberOlivier DANIEL28-Jun-10 6:02 
GeneralRe: My vote of 5 Pin
Manuel Then4-Aug-10 6:31
memberManuel Then4-Aug-10 6:31 
QuestionHow to Set Up ??? Pin
kbchiew12-Jan-09 0:20
memberkbchiew12-Jan-09 0:20 
AnswerRe: How to Set Up ??? Pin
Manuel Then12-Jan-09 4:44
memberManuel Then12-Jan-09 4:44 
QuestionFeature requests? Pin
Manuel Then31-Dec-07 1:25
memberManuel Then31-Dec-07 1:25 
AnswerRe: Feature requests? Pin
Member 475058415-Nov-08 22:51
memberMember 475058415-Nov-08 22:51 
GeneralRe: Feature requests? Pin
Manuel Then22-Dec-08 0:48
memberManuel Then22-Dec-08 0:48 
QuestionSetting return status code? Pin
rillbert14-Nov-07 9:11
memberrillbert14-Nov-07 9:11 
AnswerRe: Setting return status code? [modified] Pin
Manuel Then29-Nov-07 3:15
memberManuel Then29-Nov-07 3:15 
GeneralSuggestion of improvement Pin
rwtrecasd9-Nov-07 4:22
memberrwtrecasd9-Nov-07 4:22 
GeneralRe: Suggestion of improvement Pin
rwtrecasd12-Nov-07 7:17
memberrwtrecasd12-Nov-07 7:17 
GeneralRe: Suggestion of improvement Pin
Manuel Then29-Nov-07 3:08
memberManuel Then29-Nov-07 3:08 
GeneralThoughts on Compact Framework Pin
kcrismon15-May-07 18:52
memberkcrismon15-May-07 18:52 
QuestionWhy use it? Pin
rwtrecasd7-May-07 2:52
memberrwtrecasd7-May-07 2:52 
AnswerRe: Why use it? Pin
Manuel Then7-May-07 6:32
memberManuel Then7-May-07 6:32 
AnswerRe: Why use it? Pin
TheRaven18-Jul-11 14:55
memberTheRaven18-Jul-11 14:55 
Generalplesuggestion : a simple diagram Pin
BillWoodruff5-May-07 1:22
memberBillWoodruff5-May-07 1:22 
GeneralRe: plesuggestion : a simple diagram Pin
Manuel Then7-May-07 7:20
memberManuel Then7-May-07 7:20 
GeneralRe: plesuggestion : a simple diagram Pin
danielgianni10-Jan-08 7:50
memberdanielgianni10-Jan-08 7:50 
GeneralShort examples [modified] Pin
Paul C Smith16-Apr-07 9:16
memberPaul C Smith16-Apr-07 9:16 
GeneralRe: Short examples Pin
Manuel Then17-Apr-07 10:49
memberManuel Then17-Apr-07 10:49 
GeneralFound BUG!!!!1 Pin
rwtrecasd13-Apr-07 10:20
memberrwtrecasd13-Apr-07 10:20 
GeneralFixed Pin
Manuel Then17-Apr-07 11:08
memberManuel Then17-Apr-07 11:08 
GeneralAvoiding IIS to run several web services Pin
lonifasiko11-Apr-07 21:09
memberlonifasiko11-Apr-07 21:09 
GeneralRe: Avoiding IIS to run several web services Pin
Manuel Then12-Apr-07 6:51
memberManuel Then12-Apr-07 6:51 
GeneralRe: Avoiding IIS to run several web services Pin
lonifasiko12-Apr-07 7:22
memberlonifasiko12-Apr-07 7:22 
GeneralRe: Avoiding IIS to run several web services Pin
danielgianni29-Jan-08 11:50
memberdanielgianni29-Jan-08 11:50 
QuestionASP.NET Pin
Patrick Wolf10-Apr-07 6:50
memberPatrick Wolf10-Apr-07 6:50 
AnswerRe: ASP.NET Pin
Manuel Then10-Apr-07 10:23
memberManuel Then10-Apr-07 10:23 
AnswerRe: ASP.NET Pin
Manuel Then1-Apr-09 4:27
memberManuel Then1-Apr-09 4:27 
QuestionAddressAlreadyInUse Pin
rwtrecasd10-Apr-07 1:43
memberrwtrecasd10-Apr-07 1:43 
AnswerRe: AddressAlreadyInUse Pin
rwtrecasd10-Apr-07 1:59
memberrwtrecasd10-Apr-07 1:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151120.1 | Last Updated 15 Jul 2011
Article Copyright 2007 by Manuel Then
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid