Compare ASP.NET Web API 2 and ASP.NET Core
This content is an excerpt from the eBook, Porting existing ASP.NET Apps to .NET 6, available on .NET Docs or as a free downloadable PDF that can be read offline.
ASP.NET Core offers iterative improvements to ASP.NET Web API 2, but should feel familiar to developers who have used Web API 2. ASP.NET Web API 2 was developed and shipped alongside ASP.NET MVC. This meant the two approaches had similar-but-different approaches to things like attribute routing and dependency injection. In ASP.NET Core, there's no longer any distinction between MVC and Web APIs. There's only ASP.NET Core, which includes support for view-based scenarios, API endpoints, Razor Pages, health checks, SignalR, and more.
In addition to being consistent and unified within ASP.NET Core, APIs built in .NET Core are much easier to test than those built on ASP.NET Web API 2. We'll cover testing differences in more detail in a moment. The built-in support for hosting ASP.NET Core apps, in a test host that can create an
HttpClient that makes in-memory requests to the app, is a huge benefit when it comes to automated testing.
See Incremental ASP.NET to ASP.NET Core migration for an incremental approach to migrating to ASP.NET Core.
Submit and view feedback for