F# 和 ASP.NET [英] F# and ASP.NET

查看:18
本文介绍了F# 和 ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 F# 代码编写 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#.

这很简单:创建一个 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# 提供的一切.特别值得注意的是控制器代码变得多么短.类型推断非常好.

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 绑定器一起使用,则需要一些帮助程序代码.我写了关于它这里.

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# ASPNetCodeDomProvider 存在一些错误,使其不适合在 ASPX 页面中使用.此外,IntelliSense 在那里不起作用.因此,对于 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆