How to implement rate limiting in ASP.Net Core
When building web applications, you might often want to control the frequency of user requests to prevent malicious attacks. In other words, you might want to limit the number of requests coming from an IP address during a short timespan to mitigate denial-of-service attacks. This process is known as rate limiting.
Rate limiting enables you to control the number of requests that a client can make to an endpoint. Prior to ASP.Net Core, you had to write a lot of boilerplate code to implement rate limiting. However, implementing rate limiting is easy in ASP.Net Core. In this article, we’ll examine how we can work with rate limiting in ASP.Net Core.
Create an ASP.Net Core API project
First off, let’s create an ASP.Net Core project in Visual Studio. Assuming Visual Studio 2019 is installed in your system, follow the steps outlined below to create a new ASP.Net Core project in Visual Studio.