Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using Microsoft.AspNetCore.Mvc;
// Attribute Routing Example
[Route("products")]
public class ProductsController : Controller
{
// GET: /products
[HttpGet]
public IActionResult Index()
{
return Content("All Products");
}
// GET: /products/details/5
[HttpGet("details/{id}")]
public IActionResult Details(int id)
{
return Content("Product ID: " + id);
}
}
// Conventional Routing (Program.cs)
// app.MapControllerRoute(
// name: "default",
// pattern: "{controller=Home}/{action=Index}/{id?}");Coding works best on desktop or with an external keyboard.