views:

738

answers:

3
+6  Q: 

F# and ASP.NET

Hi, is it possible to write ASP.NET (MVC) applications with F# code? If yes, how? What possible benefits would this provide?

Thanks.

A: 

Seems it's possible... Link

DeletedAccount
+8  A: 

Yes. In fact, we're just finishing an app using ASP.NET MVC and NHibernate, with F#.

It's pretty easy: create a C# ASP.NET MVC app, then create an F# library, and put all your controllers in the F# library. (F# doesn't have a ASP.NET project type yet.)

The benefits are the same as usual -- everything F# provides. Of particular note is how short the controller code becomes. The type inference is just excellent.

If you want to use F# record types with the MVC binder, you'll need a bit of helper code. I wrote about it here.

However, with the 1.9.6.16 release, The F# ASPNetCodeDomProvider has some bugs, making it unsuitable for use in the ASPX pages. Also, IntelliSense doesn't work there. So, for the ASPX part, we used C#. Not a big deal, as that's just usually wiring up the model to the view.

MichaelGG
even the google indexed version of your blog is broken :-( (404)
Simon_Weaver
Oh crap. Thanks for pointing that out. Must be dasblog, IIS7, and me screwing up. It's the first article here though: http://www.atrevido.net/blog/
MichaelGG
Thanks for letting me know Simon. Got it fixed. IIS7 apparently doesn't like plus signs in URLs for security. Had to disable that checking ("double escaping").
MichaelGG
A: 

yes it is possible, check it out here at Arif's cyber Space

Arif