ASP.NET CORE, Web API: No route matches the supplied values

ASP.net core 3

Why this problem occurs:

As part of addressing dotnet/aspnetcore#4849, ASP.NET Core MVC trims the suffix Async from action names by default. Starting with ASP.NET Core 3.0, this change affects both routing and link generation.

See more:
ASP.NET Core 3.0-3.1 | Breaking Changes | Async suffix trimmed from controller action names

As @Chris Martinez says in this Github Issue:
.Net Core 3.0 and using CreatedAtRoute result in No route matches the supplied values. #558:

The reason for the change was not arbitrary; it addresses a different bug. If you’re not affected by said bug and want to continue using the Async suffix as you had been doing.

How to solve

Re-enable it:

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

You should now pass the createActionName parameter including the Async suffix like this:

return CreatedAtAction("PostAsync", dto)

Leave a Comment