Click here to Skip to main content
15,881,757 members
Articles / Web Development / ASP.NET

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

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
28 Jan 2013CPOL1 min read 16.6K   5   3
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:

Image 1

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 https://github.com/dmohl/FsWebSpa-Backbone.

EDIT: You can find a C# version at https://github.com/downloads/dmohl/FsWebSpa-Backbone/SpaBackbone-CSharp.zip.

This article was originally posted at http://bloggemdano.blogspot.com/feeds/posts/default

License

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


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionHow about data entry validation? Pin
atmonline9-Mar-13 6:05
atmonline9-Mar-13 6:05 
QuestionThank you Pin
JacoboPolavieja10-Feb-13 21:46
JacoboPolavieja10-Feb-13 21:46 
QuestionF# ? Pin
Ranjan.D29-Jan-13 8:19
professionalRanjan.D29-Jan-13 8: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.