dotnet / dotnet/aspnetcore

[Discussion] Async suffix for controller action names will be trimmed by default

Open
#8,998 40 comments 56 reactions 0 assignees View on GitHub
affected-most area-mvc enhancement feature-mvc-application-model severity-minor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

As part of addressing https://github.com/aspnet/AspNetCore/issues/4849, ASP.NET Core MVC will trim the suffix `Async` from action names by default. This affects routing and link generation.

Consider
```C#
public class ProductController : Controller
{
public async Task ListAsync()
{
var model = await DbContext.Products.ToListAsync();
return View(model);
}
}
```

Prior to 3.0, the action will be routeable via `Product/ListAsync`. Link generation would require specifying the `Async` suffix e.g.

`List`

In 3.0, the action will be routeable via `Product/List` and link generation would require not specifying the `Async` suffix e.g.

`List`

This change does not affect names specified using the `ActionNameAttribute`. This behavior can be disabled by setting `MvcOptions.SuppressAsyncSuffixInActionNames` to `false` as part of the application startup:

```C#
services.AddMvc(options =>
{
options.SuppressAsyncSuffixInActionNames = false;
});
```

Contributor guide

Open the contributing guide

Research direction

No files or tests are named in the issue. Start by tracing ASP.NET Core MVC action naming, routing, and link generation, then verify the Async suffix behavior, the ActionNameAttribute exception, and the SuppressAsyncSuffixInActionNames opt-out. Done means the documented 3.0 behavior is implemented and covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.