Routing in ASP.NET
Introduction
In this lesson, you will learn routing in ASP.NET for beginners. Routing is used to map URLs to specific controllers and actions in a web application.
What is Routing?
Routing decides how incoming requests (URLs) are handled by the application and which controller method should run.
Example of Routing
URL:
/home/index
This means:
- Controller → HomeController
- Action → Index()
Default Route in ASP.NET Core
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
Attribute Routing
You can define routes directly in controller.
[Route("home/index")]
public IActionResult Index()
{
return View();
}
Real-World Use
- Clean URLs for websites
- SEO-friendly page structure
- Navigation between pages
Key Points
- Routing connects URL to controller
- Helps manage navigation
- Important for SEO and structure
Internal Links
- Course Page: .NET Course for Beginners



