Monday, March 5, 2012

F# and ASP.NET Web API

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.

11 comments:

  1. Nice Blog and I am going to congratulate you to get higher traffic within your blog.There are a lot of information within your blog which is really helpful for worldwide developers and they can learn and also get a solution for their technical problem .
    It is really good that you are giving extra time to maintaining the blog and give revert back answer to all world wide developer.
    Best of luck for your upcoming career.
    (www.codeprojectdownload.com)

    ReplyDelete
  2. Nice Blog and I am going to congratulate you to get higher traffic within your blog.There are a lot of information within your blog which is really helpful for worldwide developers and they can learn and also get a solution for their technical problem .

    It is really good that you are giving extra time to maintaining the blog and give revert back answer to all world wide developer.

    Best of luck for your upcoming career.
    www.codeprojectdownload.com

    ReplyDelete
  3. in VS 11 beta, after clicking OK in step 2 I got 'Error: this template attemped to load component assembly 'FsMvc4TemplateWizard, Version 0.0.0.0' etc. It then doesn't do anything. 

    Maybe it is that nuget.org is down (at least for me)

    ReplyDelete
  4. The template uses NuGet, but doesn't actually hit nuget.org (the NuGet packages are included as part of the VSIX). Shoot me an email (dmohl at yahoo) and we can troubleshoot.

    ReplyDelete
  5. Hi,
    I've tried a "F# only Console App with SelfHosting" with use of the Web API (without ASP and c#) as you can find here http://fpish.net/topic/Some/0/74487
    and I run in some troubles, maybe you can help with just give it blink of an eye.

    Thanks in advance

    ReplyDelete
  6. Sure, I'll check it out. Though it might be a day or two due to competing priorities. 

    ReplyDelete
  7. Thank you for your fast and very helpful response on http://fpish.net/topic/Some/0/74487

    ReplyDelete
  8. This is my first comment but I feel like I should have been making loads
    of comments now because I always like your stuff. Maybe comments are
    for more hit and miss blogs than your own. When you maintain a
    consistent level of high quality output I reckon people are less
    inclined to comment because they have come to expect it from you. Just a
    theory.

    usb
    drive recovery

    ReplyDelete
  9. Your blog is really very informative. If anyone wants to get Android Training in Chennai, please refer this link..

    http://www.androidtraininginchennai.co.in/ , to know more about android.

    ReplyDelete
  10. Nice information. Thanks for sharing informative post. Android is one of the most popular mobile operating system developed by Google. Learning Android Training in Chennai is useful to make a wonderful future in mobile application development field.

    ReplyDelete