Getting ready

We can route HTTP requests to the correct Controllers by looking at what routing information is contained in the middleware of our application. The middleware then uses this routing information to see if the HTTP request needs to get sent to a Controller or not. Middleware will have a look at the incoming URL and match that up with the configuration information we provide it with. We can define this routing information in the Startup class using one of two routing approaches, namely:

  • Convention-based routing
  • Attribute-based routing

This recipe will explore these routing approaches. Before we can do that, we need to add the ASP.NET MVC NuGet package to our application. You should be rather familiar with adding NuGet packages ...

Get C# 7 and .NET Core Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.