0
3
llucycodes42
This code will respond with "Hello, Tom" if the request is for "Tom" and "Hello, world" if the request is for anything else.
Shortcut: ac_helloworld_web_api
using System;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
Console.WriteLine("http://localhost:5000/hello/test");
WebHost.Start(routes => routes.MapGet("hello/{name}", (request, response, data) => response.WriteAsync($"Hello, {data.Values["name"]}")));
Console.ReadKey();