Click here to Skip to main content
Licence CPOL
First Posted 2 Apr 2007
Views 43,740
Downloads 931
Bookmarked 39 times

Using InsomniaServer to Build a Web-interface for your Application

By | 15 Jul 2011 | Article
InsomniaServer enables you to add a fully-featured, customizable webserver to your projects. See how it works.

Introduction

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 that:)), please do not miss the InsomniaSoftware.Server.Debug namespace. I really liked it while debugging and tuning the Web interface of my software.

History

  • 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 1.0.1.0 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 1.0.2.1 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!");
      page.curNode.AddSubNode(HtmlObjects.BoldText
          ("Hello world! Sp€c?a£ cHäRa?t?r?"));

      This results in:

      <html><head><title>Hello!</title></head>
      <body>
      <b>Hello world! Sp&#8364;c&#1111;&#261;&#163; 
          cH&#228;R&#945;&#1089;t&#1028;r&#1029;</b>
      
      </body></html>  
  • 10/01/08 - InsomniaServer version 1.0.3.0 uploaded

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

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

References

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

License

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

About the Author

Manuel Then

Student

Germany Germany

Member

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 | :)

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
SuggestionIS Use Cse Scenario... PinmemberTheRaven13:51 18 Jul '11  
Questionold source ? PinmemberHamsterTrainer0110:56 13 Jul '11  
AnswerRe: old source ? PinmemberManuel Then10:12 14 Jul '11  
GeneralRe: old source ? PinmemberHamsterTrainer0111:24 14 Jul '11  
GeneralRe: old source ? PinmemberManuel Then1:38 15 Jul '11  
GeneralQuestion about performance PinmemberDr. Emmett Brown14:20 28 Jul '10  
GeneralRe: Question about performance PinmemberManuel Then5:28 4 Aug '10  
GeneralMy vote of 5 PinmemberOlivier DANIEL5:02 28 Jun '10  
GeneralRe: My vote of 5 PinmemberManuel Then5:31 4 Aug '10  
QuestionHow to Set Up ??? Pinmemberkbchiew23:20 11 Jan '09  
AnswerRe: How to Set Up ??? PinmemberManuel Then3:44 12 Jan '09  
QuestionFeature requests? PinmemberManuel Then0:25 31 Dec '07  
AnswerRe: Feature requests? PinmemberMember 475058421:51 15 Nov '08  
GeneralRe: Feature requests? PinmemberManuel Then23:48 21 Dec '08  
QuestionSetting return status code? Pinmemberrillbert8:11 14 Nov '07  
AnswerRe: Setting return status code? [modified] PinmemberManuel Then2:15 29 Nov '07  
GeneralSuggestion of improvement Pinmemberrwtrecasd3:22 9 Nov '07  
GeneralRe: Suggestion of improvement Pinmemberrwtrecasd6:17 12 Nov '07  
I answer to myself, sorry....
 
I know that I can use ContentType.FromMIME("application/x-unknown") instead of ContentType.FromType....
 
Bye
 
Alberto
GeneralRe: Suggestion of improvement PinmemberManuel Then2:08 29 Nov '07  
GeneralThoughts on Compact Framework Pinmemberkcrismon17:52 15 May '07  
QuestionWhy use it? Pinmemberrwtrecasd1:52 7 May '07  
AnswerRe: Why use it? PinmemberManuel Then5:32 7 May '07  
AnswerRe: Why use it? PinmemberTheRaven13:55 18 Jul '11  
Generalplesuggestion : a simple diagram PinmemberBillWoodruff0:22 5 May '07  
GeneralRe: plesuggestion : a simple diagram PinmemberManuel Then6:20 7 May '07  

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

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

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