Saturday, May 5, 2018

minimal .NET core web api

Hi,

today I tried to create a minimal .NET core web API application which returns a result as a foundation for a micro-service approach...

Here the code that works (pasted into main):


            WebHost.CreateDefaultBuilder(args)
                .Configure(app =>
                {
                    app.Run(async context =>
                    {
                        using (StreamWriter writer = new StreamWriter(context.Response.Body))
                        {
                            await writer.WriteAsync(await Task.FromResult("this works..."));
                        }
                    });
                })
                .Build()
                .Run();



No comments: