CassiniDev and Custom HttpHandler

Aug 27, 2010 at 1:29 PM

Hi, is it possible to use custom HttpHandler (IHttpHandler) with CassiniDev?

I wan't to build an embedded REST (GET/POST/PUT/DELETE) web service with CassiniDev.

Sep 6, 2010 at 4:56 PM

sure, anything you can do with webdev.webserver you can do with cassinidev. Simply add the line to your config.


Let me know if you have any more questions or if I misunderstand your question.

Dec 3, 2010 at 5:13 PM


I wrote a custom IHttpHandler an configured the handler in the Web.config. 


      <add verb="GET" path="/REST/*" type="WebService.Handlers.GetHandler, WebServiceNet35"/>
      <add verb="POST" path="/REST/*" type="WebService.Handlers.PostHandler, WebServiceNet35"/>

Works fine. Handlers are invoked. But there is a problem. I'm using CassiniDev to host a web-interface in my application. I this application I have a singleton instance of some kind of a "global object manager".
private Heizungsservice() {
            Manager.Instance.Load(System.IO.Path.Combine(Environment.CurrentDirectory, "config\\default.db"));
            IOInterface.IIOInterface io = new DummyIO.DummyIO();
            Manager.Instance.InitiateSystem(io, System.IO.Path.Combine(Environment.CurrentDirectory, @"Log"), true);
            _webserver = new CassiniDevServer();

            IPHostEntry localHost = Dns.GetHostEntry(Dns.GetHostName());
            for (int x = 0; x < localHost.AddressList.Length; x++) {
                if (localHost.AddressList[x].AddressFamily == AddressFamily.InterNetwork) {
                    Console.WriteLine("Server started: " + localHost.AddressList[x].ToString());

Now I have to Access this singleton from the HttpHandler, but It seems the handler creates a totally new Instance of my Singleton object. I've using an other embedded web server the same way on a Windows CE machine, and there it works.

What can I do to be able to access the originally singleton class? It's a hvac controller which have to run all the time.

How to communicate across this boundaries?? :-( Hopefully I doesn't need to implement some kind of IPC !

Dec 17, 2010 at 3:31 AM

Chris, Sorry I have not been around to investigate this. I will make some time for it this weekend. 


Mar 12, 2011 at 1:29 AM

I have not yet written any tests for this but as I re-examine your replies it would seem that if your manager has a static instance and it is getting recreated that a new app domain is being created. this can happen after a certain timeout period as does in IIS.

I will write some tests and investigate.

Mar 12, 2011 at 1:32 AM

BUT - while your issue is absolutely valid and Cassinidev ( or webdev) can be used to serve most any content, using it for a mission critical production scenario is NOT recommended.

The stated mission of Cassinidev is to provide a rich test server with value add.  Anything on top of that is gravy. Luckily I like gravy so let's see if we can get to the bottom of this one way or the other.


Aug 25, 2011 at 2:07 PM


I started replacing my own little http server in an app, and now i have the same problem.

Did you find a sollution for this?