Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async suffix for controller action names will be trimmed by default #351

Open
pranavkm opened this Issue Apr 2, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@pranavkm
Copy link
Member

pranavkm commented Apr 2, 2019

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

Consider

public class ProductController : Controller
{
    public async IActionResult 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.

<a asp-controller="Product" asp-action="ListAsync">List</a>

In 3.0, the action will be routeable via Product/List and link generation would require not specifying the Async 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 to false as part of the application startup:

services.AddMvc(options =>
{
   options.SuppressAsyncSuffixInActionNames = false; 
});
@pranavkm

This comment has been minimized.

Copy link
Member Author

pranavkm commented Apr 2, 2019

Please use aspnet/AspNetCore#8998 for further discussions.

@aspnet aspnet locked and limited conversation to collaborators Apr 2, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.