F#和ASP.NET [英] F# and ASP.NET
问题描述
是有可能写在F#code ASP.NET(MVC)应用程序?如果是的话,怎么样?这会提供什么样的可能的好处?
is it possible to write ASP.NET (MVC) applications with F# code? If yes, how? What possible benefits would this provide?
感谢。
推荐答案
是的。事实上,我们刚刚完成使用ASP.NET MVC和NHibernate应用,而在F#。
Yes. In fact, we're just finishing an app using ASP.NET MVC and NHibernate, with F#.
这是pretty简单:创建一个C#ASP.NET MVC应用程序,然后创建一个F#库,并把所有的控制器在F#库。 (F#没有一个ASP.NET项目类型呢。)
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.)
好处是和往常一样 - 一切F#提供。特别值得注意的是控制器code多短就越大。该类型推断仅仅是出色的。
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.
如果你想使用F#记录类型与MVC粘结剂,你需要一个帮手位code的。我写在这里 。
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.
不过,随着1.9.6.16版本中,F#ASPNET codeDomProvider有一些错误,使得它不适合在ASPX页面使用。此外,智能感知这里是行不通的。因此,对于ASPX部分,我们使用C#。没什么大不了的,因为这只是一般的模型连接最多的观点。
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.
这篇关于F#和ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!