ASP NET Core Creates a HelloWorld sample WebApi

    0

    3

    lucycodes42

    C# recipes

    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();
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.