【发布时间】:2016-07-08 21:07:41
【问题描述】:
有人可以分享用 F# 编写的最小工作 ASP.NET Core 应用程序项目吗?
要在 C# 中实现一个最小的演示,我们必须执行以下操作:
mkdir aspnetcoreapp
cd aspnetcoreapp
dotnet new
然后编辑project.json:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0"
},
"imports": "dnxcore50"
}
}
}
然后执行dotnet restore并使用以下代码:
Startup.cs:
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
namespace aspnetcoreapp
{
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.Run(context =>
{
return context.Response.WriteAsync("Hello from ASP.NET Core!");
});
}
}
}
Program.cs:
using System;
using Microsoft.AspNetCore.Hosting;
namespace aspnetcoreapp
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
}
然后执行dotnet run。谁能给我一个提示如何在 F# 中做同样的事情?
【问题讨论】:
-
嗨,我想如果你对 F# ASP.NET Core Web 开发感兴趣,那么你可能会对这个 NuGet 库感兴趣:github.com/dustinmoris/AspNetCore.Lambda。我还在这里写了博客:dusted.codes/functional-aspnet-core
标签: .net f# asp.net-core