Skip to content

Instantly share code, notes, and snippets.

@aensidhe
Last active August 12, 2019 06:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aensidhe/1852bac59db379d3af250e1ea44a7eb1 to your computer and use it in GitHub Desktop.
Save aensidhe/1852bac59db379d3af250e1ea44a7eb1 to your computer and use it in GitHub Desktop.
Almost minimal asp.net core sample
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
namespace MinimalAspNetCore
{
internal class Program
{
private static void Main(string[] args) => WebHost.CreateDefaultBuilder(args).UseStartup<Program>().Build().Run();
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.Map(new PathString("/ping"), x => x.Run(Ping));
app.Map(new PathString("/pong"), x => x.Run(Pong));
}
private static async Task Ping(HttpContext context) => await context.Response.WriteAsync("PING RESPONSE");
private static async Task Pong(HttpContext context) => await context.Response.WriteAsync("PONG RESPONSE");
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" />
</ItemGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment