A few weeks ago the ASP.NET team announced the release of ASP.NET MVC 4 Beta. You can read about it here. One of the exciting features that was announced is ASP.NET Web API. ASP.NET Web API provides an excellent programming model for building HTTP services.
One of the sweet spots for F# is in the services layer and this makes ASP.NET Web API + F# great friends. To make it easy to get started with F# and ASP.NET Web API, I’ve added an ASP.NET Web API template to the already existing F#/C# ASP.NET MVC 4 Visual Studio extension. Note: The template requires that ASP.NET MVC 4 Beta is installed.
To install the template, do the following:
1. Launch the project creation wizard (Ctrl+Shift+N), select Online in the left hand nav, search for “fsharp mvc4″, and click OK. In VS11 Beta, it looks something like the following. Note: It may take a few seconds to download.
2. After clicking OK and installing the extension, you will see a dialog that allows the creation of a new ASP.NET Web API solution with an F# project that contains the server-side code.
3. Once the project has been created, you can run it however you desire and hit the service via http://localhost:###/api/values.