Licensed for testing and evaluation purposes. You can use the source code of the tutorial if you are a licensed user of DayPilot Pro for ASP.NET WebForms.


DayPilot is a calendar/scheduling control for ASP.NET. If you want to use it in a desktop WinForms application you need to use a WebBrowser control and an embedded web server.

Embedded ASP.NET Web Server (Cassini)

Cassini is a simple web server created by Microsoft and made available under the Microsoft Public License

It's no longer available for download from Microsoft but a few forks are available and one of them is hosted at codeplex (Cassinidev).

We will use the core part of Cassini to run our web server on localhost.

Sample Visual Studio Solution

daypilot desktop visual studio solution

The sample Visual Studio 2010 solution includes three projects:

  • App (a web project with DayPilot)

  • WebServer (Cassini web server, compiled as a dll)

  • Desktop (the wrapper WinForms application, running App using WebServer)

Desktop Application

daypilot desktop form1

The desktop application is a simple Form with a WebBrowser control.

Upon loading, we start the embedded web server and navigate to the home page:

 private void Form1_Load(object sender, EventArgs e)
  string appPath = Path.GetFullPath("..\\..\\..\\App");

  Server server = new Server(0, "/", appPath);

  webBrowser1.Url = new Uri(server.RootUrl);

The Cassini source was updated a bit to support dynamic port assignment:

  • It chooses a free port if you use 0 as the port number.

  • The actual port number is part of RootUrl string.

WebBrowser Control and IE Rendering Mode

By default, the Internet Explorer used in the WebBrowser control runs in IE7 standards mode - see  More IE8 Extensibility Improvements [].

In order to avoid IE7 bugs, you can switch to a higher rendering mode. We are switching to IE8 standards mode by adding the application name and rendering mode code (8000) to HKCU\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION registry key:

 public void BrowserEmulation()
  String application = Process.GetCurrentProcess().ProcessName + ".exe";
  RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", RegistryKeyPermissionCheck.ReadWriteSubTree);
  if (key != null)
      key.SetValue(application, 8000, RegistryValueKind.DWord);
    catch (Exception ex)

See also codes for other rendering modes [].