ASP.NET Core MVC

Understanding Controllers

In ASP.NET Core MVC, a controller is a class that handles incoming HTTP requests, processes user input, interacts with a model, and selects a view to render the response.

Action Methods

An action method is a public method on a controller that can be invoked via a URL. By default, action methods return an IActionResult which can be a view, JSON, redirect, etc.

Routing to Actions

The default routing pattern maps URLs to controller actions in the form /[controller]/[action]/{id?}. You can customize routes with attributes.

Try It Yourself

Enter a product ID to see how the Details action would be called.