What is a server? Your first response

What a program, a server, and a route are.

1. What is this?

A server is a program that waits for requests and sends responses. In ASP.NET Core, a route maps a URL to code: app.MapGet("/", () => "Hello") means 'when someone visits /, reply Hello'. The example below is console C# (runnable here); the web form is shown so you recognise it.

2. Why do we use it?

Login, checkout, feeds — all are requests answered by servers. .NET is a mainstream way to build them reliably.

3. Syntax breakdown

  • Console.WriteLine("Hello from .NET");

    Prints a line — runnable in this editor to confirm your setup works.

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

    Web form (read-only here): route / replies Hello. () => ... is a small function.

  • app.Run();

    Starts the server so it listens for requests.

5. Common mistakes

  • Trying to run app.MapGet in the console runner — it needs a web host; the runnable part here is the Console line.
  • Forgetting app.Run() so the server never starts.
  • Confusing the URL path ("/") with the returned text.

Practice task

Change the message to "Hello, <your name>, from .NET" and run.

Hint

Edit the string inside WriteLine.

Try it below — tests run automatically when you press Run.

dotnet

Output

Press Run to see output.

Mini quiz

3 questions. Answer, then check.

  1. 1. What is a server?

  2. 2. What does app.MapGet("/", ...) do?

  3. 3. What starts an ASP.NET Core server?

4. Example — edit and run

dotnet

Output

Press Run to see output.

Expected output: Hello from .NET