Creating a simple API Gateway in ASP.NET Core

Mircea Oprea
StreamWriter
Published in
5 min readJun 4, 2018

--

If you are interested in developing full-stack ASP.NET Core web applications, check out my e-book on this subject or buy it directly.

In a previous article of mine, JWT Authentication for Microservices in .NET, I have looked into creating an authentication microservice. This would be used to validate the identity of the user’s identity before performing any action in other components of the system.

A microservice architecture diagram

Another component that is crucial to this process is the API gateway — basically, a middleware system that routes the incoming requests to the responsible microservice, but also performs the identity validation before doing so.

There are many frameworks that can be used for setting up an API gateway, such as Ocelot, in .NET Core, or Netflix Zuul, in Java. However, in this article I will go over the process of creating a simple API gateway from scratch, in .NET Core.

Creating the project

The first step is to create a new ASP.NET Core Web Application project is Visual Studio. Since this project will only act as middleware, choose Empty as the template.

--

--