ASP.NET Core Interview Question #23
What is routing in ASP.NET Core?
ASP.NET Core Fundamentals Junior Beginner
Quick Interview Answer
Routing matches incoming HTTP requests to executable endpoints and can also generate URLs for application endpoints.
Detailed Explanation
Routing matches incoming HTTP requests to executable endpoints and can also generate URLs for application endpoints.
ASP.NET Core supports conventional routing, attribute routing, Razor Pages routing, minimal API route mappings, and endpoint metadata. Route values can identify controllers, actions, resource identifiers, and other parameters.
Routing is a foundational part of MVC and Web API applications because it determines which endpoint handles a request.
Code Example
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");