is it possible to write ASP.NET (MVC) applications with F# code? If yes, how? What possible benefits would this provide?
Thanks.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With