You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Async suffix for controller action names will be trimmed by default
As part of addressing dotnet/aspnetcore#4849, ASP.NET Core MVC will trim the suffix Async from action names by default. This affects routing and link generation.
Version introduced
3.0
Old behavior
Consider the following ASP.NET Core MVC controller:
Asynchronous .NET methods, by convention, end with the Async suffix. However, when a method defines an MVC action, it is generally not desirable to have the Async suffix.
Recommended action
If your application depends on MVC actions retaining the Async suffix in the name, you can:
Use ActionNameAttribute to preserve the original name
Disable this renaming entirely by setting MvcOptions.SuppressAsyncSuffixInActionNames to false as part of the application startup:
Async suffix for controller action names will be trimmed by default
As part of addressing dotnet/aspnetcore#4849, ASP.NET Core MVC will trim the suffix
Async
from action names by default. This affects routing and link generation.Version introduced
3.0
Old behavior
Consider the following ASP.NET Core MVC controller:
Prior to 3.0, the action will be routeable via
Product/ListAsync
. Link generation would require specifying theAsync
suffix e.g.<a asp-controller="Product" asp-action="ListAsync">List</a>
New behavior
In 3.0, the action will be routeable via
Product/List
and link generation would require not specifying theAsync
suffix e.g.<a asp-controller="Product" asp-action="List">List</a>
This change does not affect names specified using the
ActionNameAttribute
.This behavior can be disabled by setting
MvcOptions.SuppressAsyncSuffixInActionNames
tofalse
as part of the application startup:Reason for change
Asynchronous .NET methods, by convention, end with the
Async
suffix. However, when a method defines an MVC action, it is generally not desirable to have theAsync
suffix.Recommended action
If your application depends on MVC actions retaining the
Async
suffix in the name, you can:ActionNameAttribute
to preserve the original nameMvcOptions.SuppressAsyncSuffixInActionNames
tofalse
as part of the application startup:Category
Affected APIs
Not detectable via API analysis
Issue metadata
The text was updated successfully, but these errors were encountered: