在Debian系统中,使用F#编写并运行OWIN应用程序
环境
-
- Debian 8.1
-
- .NET Framework 4.6
-
- Visual Studio 2015 RC
- Visual Studio 2013
使用 F# 创建 OWIN 应用程序
源代码放在这里。
1. 创建项目
由于Visual Studio 2015的错误导致F#模板完全崩溃,所以只能使用Visual Studio 2013进行项目的新建。
这个问题在正式版本中得到了修复。

我会使用Visual Studio 2015重新打开已创建的项目。
(只是想使用新版本,但不继续在2013版本上进行也没有问题)
2. 添加引用
由于下面的DLL文件是必需的,所以需要从NuGet中获取。
-
- Microsoft.Owin
-
- Microsoft.Owin.Host.HttpListener
-
- Microsoft.Owin.Hosting
- Owin

3. 制作调料

open System
open Microsoft.Owin.Hosting
open Startup
[<EntryPoint>]
let main _ =
let baseAddress = "http://*:9000"
use app = WebApp.Start<Startup>(baseAddress)
Console.WriteLine("Listening at {0}", baseAddress)
Console.WriteLine("Press any key to stop")
Console.ReadLine() |> ignore
0
module Startup
open System
open global.Owin
type Startup() =
member this.Configuration(app:IAppBuilder) =
let os = "<h1>OWIN on " + Environment.OSVersion.ToString() + "</h1>"
app.Run(fun c -> c.Response.WriteAsync(os))


在Debian服务器上安装Mono。
按照上述步骤安装Mono。
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
$ echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
# Debianの場合はこれも必要
$ echo "deb http://download.mono-project.com/repo/debian wheezy-libjpeg62-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
$ sudo apt-get update
$ sudo apt-get -y install mono-devel
我成功安装了。
$ mono -V
Mono JIT compiler version 4.0.2 (Stable 4.0.2.5/c99aa0c Wed Jun 24 10:04:37 UTC 2015)
打开应用程序

执行exe文件。
$ mono fsharp_owin_sample.exe

请使用以下资料作为参考。
使用Mono和OWIN在Raspberry Pi上运行ASP.NET
swlaschin/Railway-Oriented-Programming-Example。