Posts

Implement Rate Limiting In ASP.NET Core Web API

Image
Introduction In this article, you'll learn about rate limiting and how to apply it to your ASP.NET Core Web API. What is Rate Limiting? If you're building an API, it might be accessed by multiple clients. Sometimes, certain clients use the API excessively without any restrictions. However, if you need to control how often a specific client can use the API within a set timeframe, you can achieve this through Rate Limiting. Rate Limiting is like setting a speed limit on how many times someone can ask for something from a website or app in a certain amount of time. It means each person or device using the service can only ask for a certain number of things within a particular timeframe. Why do we need Rate Limiting? Rate Limiting is a useful tool for safeguarding against harmful bot attacks. Imagine a hacker sending bots to repeatedly request access to an API endpoint. This flood of requests can ove...

.Net Core vs .Net framework

Image
  In the ever-evolving landscape of software development, choosing the right framework can make all the difference. Two prominent contenders in the .NET ecosystem are .NET Core and .NET Framework. In this comprehensive guide, we delve into the intricacies of both, helping you make an informed decision for your next project. Understanding .NET Core .NET Core , developed by Microsoft, stands as a testament to innovation in the world of software engineering. It is an open-source, cross-platform framework that allows developers to build high-performance applications for various platforms, including Windows, Linux, and macOS. .NET Core boasts an extensive set of libraries, making it a go-to choice for modern, scalable, and cloud-based applications. Key Features of .NET Core Cross-Platform Compatibility: One of the significant advantages of .NET Core is its ability to run on multiple operating systems, ensuring seamless deployment across diverse environments. ...

The Key Features of .Net 8

Having a regular schedule for releasing .NET updates is great. In the past, when using the older .NET Framework, updates were infrequent and didn't bring significant changes. While it wasn't necessarily a problem, the issue was that the development platform's progress was linked to Windows updates, which could mean waiting for years to access new features. Since transitioning to an open-source platform, especially with the simultaneous development of .NET Core and the .NET Standard base classes, and later the integration into a unified .NET, there have been significant improvements. Now, we receive a yearly update for .NET, connected to the .NET Conf event held in November. These updates come with 18 months of support for STS (Standard Term Support) releases and three years of support for LTS (Long Term Support) releases. It's worth noting that STS releases are odd-numbered versions, while even-numbered versions are designated as LTS. ...

Fluent Validation in .Net core

  In every application, making sure the data is accurate and error-free is crucial. In .NET Core applications, handling this validation process has become easier and more understandable, thanks to FluentValidation. FluentValidation is a popular library that lets you define and apply validation rules in a clear and readable way. In this blog post, we'll dive into how to use FluentValidation to simplify data validation in your .NET Core projects. What is FluentValidation? FluentValidation is a free-to-use library in .NET that offers a clearer and easier method to validate data. It's particularly well-liked in ASP.NET Core applications, where checking user inputs in forms, API requests, and other data is often necessary. With FluentValidation, you can create validation rules using a clear and straightforward syntax. This makes your validation logic easy to comprehend and manage, making the process of checking data much simpler. Getting St...

ASP Net Core Cookie Authentication With SPA

ASP.NET Core is a fantastic framework for web applications, representing a significant leap in architecture design compared to ASP.NET MVC. However, as I began working with it, I noticed it has strong opinions about how certain things should be done. These preferences are evident not just in the framework itself but also in various tutorials and blog posts created around it. If you prefer doing things in your own way, finding assistance can be challenging. One common preference is using the Authorization header token authentication, like JWT, for Single Page Applications (SPA). Personally, I struggled to find tutorials or documentation explaining how to use cookie authentication for SPAs in ASP.NET Core. I won't get into the ongoing debate about whether this idea is good or not, as there are plenty of blog posts and videos discussing it already. In this article, I will show you how I managed to set up cookie authentication in a Single Page Applica...

Should you adopt .NET 7 or wait for .NET 8?

  Introduction Is waiting worth it, even in the realm of software frameworks? As technology keeps progressing, new and better frameworks are introduced to match the latest innovations like AI. With the imminent arrival of .NET 8, developers might be curious about what makes it a better choice than .NET 7. In this post, we'll delve into the improvements that make .NET 8 an excellent option for developers aiming to stay at the forefront of technology. But if you're using .NET 7 now, don't rush; there's time to consider your options. Better Performance In every new version of .NET, making things faster is a top priority. .NET 8 takes a step beyond .NET 7 by refining the Just-In-Time (JIT) compiler, garbage collector, and runtime. This means applications start up more quickly, use less memory, and perform better overall. These improvements make .NET 8 a great choice for developers who want to optimize their applications and make them...

What is Signal-R in c#

Introduction: In today's world, modern applications must keep users updated in real-time. This means providing timely information as events happen. Historically, enabling real-time communication in applications was a complex task, but thanks to SignalR, it has become much simpler. SignalR is a library specifically designed for .NET applications, offering powerful real-time communication capabilities. In this article, we will explore SignalR, its key features, and how to seamlessly integrate it into your C# applications to achieve real-time communication. What is SignalR? The SignalR library is a valuable tool for .NET applications, providing the capability for real-time communication. What this means is that you can enhance your applications so that users receive updates instantly as they occur, without the need for them to manually refresh the page. This feature significantly improves the user experience...

Custom Middleware in .Net core 6.0

Image
  We will now write a custom middleware to avoid inline middleware in Program.cs.  The custom middleware will be written to a different class. Please keep the following in mind when writing custom middleware. There are several components that must be included in the middleware class: RequestDelegate is a public constructor with a parameter. Invoke or InvokeAsync is a public method that should return a Task. HttpContext should be the first parameter With IApplicationBuilder, an extension method is created for exposing the Middleware. Dependency Injection can be used to populate additional parameters for the constructor and for Invok/InvokeAsync. Let's quickly dive into Visual Studio and start building a middleware. In this tutorial, I'll be utilizing the following tools: Visual Studio Community Edition 2022 (64-bit) .NET 6.0 Minimal Web API Swagger There are three different methods ...