When your banking app shows your balance, the phone is not calculating it locally — it asks a server somewhere secure. That conversation happens over the internet using an API. Your console app from Lesson 6 talked to one person at a keyboard. Web APIs talk to thousands of phones, browsers, and partner systems at once.
ASP.NET Core is Microsoft's toolkit for building those servers in C# on .NET. Let us demystify HTTP, endpoints, and JSON without drowning in configuration.
What Is a Web API?
An API (Application Programming Interface) is a defined way for programs to request services from other programs. A Web API does this over HTTP — the same protocol your browser uses for websites.
Think of a restaurant again: the mobile app is the customer, the kitchen is the server, and the API is the waiter carrying orders and plates. The customer never walks into the kitchen; they use a standard menu (the API contract).
HTTP methods describe the intent:
GET— read data (fetch balance)POST— create something (place order)PUT/PATCH— updateDELETE— remove
What Is ASP.NET Core?
ASP.NET Core is the web framework sitting on .NET. It handles incoming HTTP requests, routes them to your C# methods, and formats responses — usually as JSON (JavaScript Object Notation), a text format both apps and browsers understand.
JSON looks like:
// Conceptual JSON response
{ "accountId": 42, "balance": 15000.50, "currency": "INR" }
Your C# classes from Lesson 5 can map to JSON automatically — the framework serializes properties into text and back.
Your First Endpoint
Create a Web API project:
dotnet new webapi -n BalanceApi --use-controllers false
cd BalanceApi
Minimal API style keeps the first example short:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/api/balance/{accountId}", (int accountId) =>
{
// Demo data — real apps read from a database (Lesson 8)
return new { AccountId = accountId, Balance = 15000.50, Currency = "INR" };
});
app.Run();
Run with dotnet run, then visit https://localhost:7xxx/api/balance/42 in a browser. You should see JSON — your first live API response.
Request Flow
Mobile banking app
↓ HTTP GET /api/balance/42
ASP.NET Core (Kestrel web server)
↓ routes to your C# lambda
Returns JSON { balance: 15000.50 }
↓
App displays balance on screen
Kestrel is the built-in web server listening for requests. In production, Kestrel often sits behind a reverse proxy like nginx or Azure Front Door — but locally, it is enough.
Real-World Example
Netflix's mobile app calls dozens of APIs: profile list, continue watching, search results. Each endpoint is a small C# (or other language) method on a server farm. When you tap a thumbnail, a GET request fetches metadata; when you rate a show, a POST sends your rating back.
ASP.NET Core gives you routing, authentication hooks, logging, and performance tuning — infrastructure WhatsApp-scale teams need, available to your student project too.
Common Misconceptions
"APIs always return HTML." Web APIs return data (JSON/XML). HTML is for human-facing pages — a different ASP.NET Core style (Razor Pages/MVC).
"REST is a Microsoft product." REST is a design style for URLs and HTTP verbs. ASP.NET Core helps you implement RESTful APIs, but the idea is universal.
"I need IIS to run locally." On Mac/Linux/Windows, Kestrel runs out of the box. IIS is optional on Windows servers.
"One giant endpoint should do everything." Small, focused endpoints are easier to secure, test, and cache — like separate WhatsApp features (chat, calls, status) sharing one app but different services.
Quick Recap
- Web APIs expose server logic over HTTP.
- ASP.NET Core routes requests to C# code and returns JSON.
MapGetdefines a GET endpoint path.- Mobile and web clients consume APIs — they do not embed your C# directly.
- Lesson 8 connects APIs to persistent data with Entity Framework.
Summary
ASP.NET Core turns your C# skills outward — from a terminal on your laptop to services the whole internet can call. Like upgrading from practising dialogues alone to hosting a call centre, the same language now serves many clients at once.
Next: storing account balances and orders in a real database with Entity Framework Core.
Frequently Asked Questions
GET /api/balance/42.Key Takeaways
- Web APIs let clients fetch and send data over HTTP.
- ASP.NET Core routes requests to C# and formats JSON responses.
- HTTP verbs express intent: GET read, POST create, etc.
- Minimal APIs are a simple starting point before controllers.
- Your Lesson 6 logic can power endpoints — add HTTP around it.