Using CassiniDev to host ASP.Net in your application

The use cases for self hosted web content, be it static content or compiled resources such as ASP.Net pages, modules, handlers, WCF services, are numerous. Some example are Remote Control, Help systems, Dynamic UI and Template based code generation.

There are many examples available of using SimpleWorkerRequest to host ASP.Net content within your application. This generally provides very basic functionality and requires quite a bit of code.

With CassiniDev this process is simplified to a few lines of code and provides the benefit of a full ASP.Net server implementation.

Simple self hosting example - (from project SelfHostingCassiniDev)
using System;
using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
using CassiniDev;

namespace SelfHostingCassiniDev
    public class Form1 : Form
        private readonly CassiniDevServer _server;
        private readonly IContainer _components;
        private WebBrowser _webBrowser1;

        public Form1()

            _server = new CassiniDevServer();

            // our content is Copy Always into bin
            _server.StartServer(Path.Combine(Environment.CurrentDirectory, "WebContent"));


        private void Form1_FormClosing(object sender, FormClosingEventArgs e)

        protected override void Dispose(bool disposing)
            if (disposing && (_components != null))

        private void InitializeComponent()
            this._webBrowser1 = new System.Windows.Forms.WebBrowser();
            // _webBrowser1
            this._webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
            this._webBrowser1.Location = new System.Drawing.Point(0, 0);
            this._webBrowser1.Name = "_webBrowser1";
            this._webBrowser1.Size = new System.Drawing.Size(355, 269);
            this._webBrowser1.TabIndex = 0;
            // Form1
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(355, 269);
            this.Name = "Form1";
            this.Text = "Form1";
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);


Last edited May 19, 2010 at 1:06 PM by Sky, version 2


Vitalick Mar 21, 2013 at 7:48 PM 
Very useful server (for simple). Great Thanks! Will be support you how I can. (russia)