Click here to Skip to main content
13,346,713 members (67,450 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


5 bookmarked
Posted 28 Jan 2013

A Single Page App with Backbone.js, ASP.NET Web API, and F#

, 28 Jan 2013
Rate this:
Please Sign up or sign in to vote.
A simple example of a single page application built with Backbone.js, ASP.NET Web API, F#, and more.

In this post, I introduce a simple example of a single page application built with Backbone.js, ASP.NET Web API, F#, and more. The example is an overly simple contacts app that allows you to view contacts and create new ones. It uses the Foundation 3 framework for styling and responsive design.

Here's a screenshot of the simple contact list view:

Solution Organization

The C# project contains the following:

  • A single Index.cshtml file.
  • All images, CSS, and JavaScript.
  • A "Templates" folder that contains 2 .htm files that hold the markup for each view. The templating feature of underscore.js is used to allow placeholders in the templates to be replaced with the desired data.

The heart of the client-side code is broken into 3 folders within the Scripts folder of the C# project:

  • The "app" folder contains a main.js, a utility.js, and a file containing route definitions using Backbone.Router.
  • The "models" folder contains the Backbone models and collections.
  • The "views" folder contains Backbone views.

The F# project contains the following:

  • ASP.NET MVC and Web API routes
  • Definitions of JS and CSS bundles
  • ASP.NET MVC and Web API Controllers
  • A Model class

Getting the Code

You can find the full source at

EDIT: You can find a C# version at


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


About the Author

United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionHow about data entry validation? Pin
atmonline9-Mar-13 7:05
memberatmonline9-Mar-13 7:05 
QuestionThank you Pin
JacoboPolavieja10-Feb-13 22:46
memberJacoboPolavieja10-Feb-13 22:46 
@Daniel: Thank you very much for providing these samples applications. You are the main source of these kind of F# for the web, so thank you for all of this, it is truly useful.
Have you played with Event Sourcing & CQRS with F#? I think they should fit pretty nicely, but seems an overwhelming project for my actual programming level.

@Ranjan: The advantages are the usual on F# vs C#, some of those being: shorter and more expressive code, more easily achievable performance over multicores, etc. You can just google the differences between both languages and that applies to the web scenario also. But in particular, I think not having objects per se and just reusable functions and data structures fits nicely in the web model. With no need to have your project depend on dependency injection, etc, everything is just cleaner in my eyes. Beware that programming in a functional style VS an object oriented one can be daunting at first, but it is then all so logical one wonders why this isn't more widespread.
QuestionF# ? Pin
Ranjan.D29-Jan-13 9:19
memberRanjan.D29-Jan-13 9:19 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 28 Jan 2013
Article Copyright 2013 by danmohl
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid