DEV Community

Discussion on: A Node.js Developer Tries .NET

Collapse
 
aaronblondeau profile image
aaronblondeau

So, I tried an empty ASP.Net project and what I found looks extremely familiar. All the boilerplate code is gone and I can setup regular http methods like I am used to :

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

app.MapPost("/thing", async context => {
    Thing thing = await context.Request.ReadFromJsonAsync<Thing>();
    await context.Response.WriteAsJsonAsync(thing);
});

app.Run();

public class Thing
{
    public string name { get; set; } = "";
}
Enter fullscreen mode Exit fullscreen mode