Building RPC-style Web APIs

The RPC-style is based on the Remote Procedure Call paradigms, which have existed for a long time now (since the early 1980s). It is based on including an action name in the URL, which therefore makes it very similar to standard MVC actions.

One of the big advantages of ASP.NET Core 2.0 is that you do not need to separate the MVC parts from the Web API parts. Instead, you can use both in your controller implementations.

Controllers are now capable of rendering View results as well as JSON/XML API responses, which enables easy migrations from one to the other. Additionally, you can use a specific route path or the same route path for your MVC actions.

In the following example, you are going to transform a controller ...

Get Learning ASP.NET Core 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.