Ai đó có thể chia sẻ dự án ứng dụng ASP.NET Core làm việc tối thiểu được viết bằng F #?Dự án ASP.NET Core 1.0 F #
Để thực hiện một bản demo tối thiểu bằng C#, chúng ta phải làm như sau:
mkdir aspnetcoreapp
cd aspnetcoreapp
dotnet new
Sau đó chỉnh sửa 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"
}
}
}
Sau đó thực hiện dotnet restore
và sử dụng mã follwoing:
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();
}
}
}
Sau đó thực hiện dotnet run
. Ai có thể cho tôi một gợi ý làm thế nào để làm điều tương tự trong F #?
chào, tôi nghĩ nếu bạn quan tâm đến F # ASP.NET Core phát triển web sau đó bạn có thể quan tâm đến thư viện NuGet này: https://github.com/dustinmoris/AspNetCore.Lambda. Tôi cũng viết blog về nó ở đây: https://dusted.codes/functional-aspnet-core – dustinmoris