Skip to content
Learn Netverks

Lesson

Step 17/36 47% through track

routing-intro

Routing intro

Last reviewed May 28, 2026 Content v20260528
Track mode
server_compiled
Means
Compiled runner
Reading
~1 min
Level
beginner

This lesson

An orientation to the ASP.NET track—how the server playground works, core vocabulary, and what you will practice next.

You need a clear map of the ASP.NET track so middleware, dependency injection, and the .NET project layout do not feel like magic.

You will apply Routing intro in contexts like: Line-of-business APIs, intranets, BFF layers, and cloud-hosted services on Linux or Windows.

Write C# (top-level or Program class), click Run on server—the dev runner uses dotnet build/run on a temp net8 project (requires .NET SDK; LEARNING_RUNNER_ENABLED=true). Also read the interview prep blocks.

After HTML fundamentals and basic programming concepts—before or alongside SQL.

Routing maps URLs to code—controller actions, Razor Pages, or minimal API delegates. Convention-based MVC routes use {controller}/{action}/{id?}; attribute routing uses [Route] and [HttpGet] on methods.

Convention route

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

/Products/Details/5ProductsController.Details(5)

Attribute routing (Web API)

[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase {
    [HttpGet("{id:int}")]
    public IActionResult Get(int id) => Ok(/* ... */);
}

Important interview questions and answers

  1. Q: Convention vs attribute routing?
    A: Convention centralizes patterns in Program.cs; attributes colocate routes with actions—APIs favor attributes.
  2. Q: Route constraints?
    A: {id:int} rejects non-integers with 404—stronger than string parsing in the action.

Self-check

  1. Which URL hits HomeController.Index() with default route?
  2. What does [controller] token expand to?

Interview prep

Convention vs attribute routing?

Convention centralizes patterns in Program.cs; attribute routes colocate with actions—Web APIs typically favor [Route] and [HttpGet] on methods.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Attribute vs conventional?
  • MapControllers?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump