Our First Controller

Before creating the controller, we need to remove the following app.Run statement as this will return Hello World! for all the incoming requests. As we want incoming requests to be handled by the controllers, we need to remove the following code from the Configure method of the Startup class:

app.Run(async (context) =>{  await context.Response.WriteAsync("Hello World!");};

We have installed ASP.NET Core in our application. So, we are geared up for creating our first ASP.NET Core controller. Create a folder with the name Controllers and add a new controller from the context menu, as shown in the following screenshot:

Context ...

Get ASP.NET Core 2 Fundamentals 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.