Mapping CancellationToken in controller's actions

Author: juchomCreated Sep 29, 2021Updated Sep 30, 2021

We often see code like that

csharp
public async Task<IActionResult> Get()
{
    await Task.Delay(1000);
    return View();
}

Is it a good practice to add the CancellationToken parameter to actions when it goes async and pass this parameter to async methods ?

csharp
public async Task<IActionResult> Get(int id, CancellationToken cancellationToken)
{
    await Task.Delay(1000, cancellationToken);
    return View();
}

Source: davidfowl/AspNetCoreDiagnosticScenarios