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...

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 ...

.NET 7 features of Microsoft’s cloud-first

Image
Microsoft's significant open-source platform, .NET 7, was unveiled during this year's .NET Conf. In addition to improved tooling, there are new language releases for C# and F#, along with the introduction of the cross-platform MAUI user interface framework. Moreover, a new version of ASP.NET Core and Blazor has been released for developing web applications on both the server and client sides. Additionally, there's a significant update to the Orleans distributed application development framework, which now aligns with .NET's naming scheme. Microsoft and the .NET Foundation have effectively transitioned the platform to an annual update schedule, prioritizing features through open development and incorporating community-contributed code. The shift from the Windows-exclusive .NET Framework to .NET Core, and now to a unified .NET release, has provided developers with a single cross-platform development platform. This expansion includes the addition of Linux and macOS support...

How to Optimizing Query Performance in Laravel

Image
In this article, we will explore the process of checking the execution time of queries in Laravel. By the end, you will clearly understand how to obtain the query execution time in Laravel. Additionally, we will provide practical examples, ensuring you grasp the concept effectively. This tutorial is applicable to various versions of Laravel, including 6, 7, 8, 9, and 10. If you're specifically interested in obtaining the SQL query execution time in Laravel, we will present two examples for your convenience. We will use the 'microtime()' function and the 'enableQueryLog()' feature to accurately calculate the query execution time in Laravel.  so, let's see the simple example code: Demonstration: 1 TestController.php <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\User; class TestController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response ...

ASP.NET 7 new features

Image
ASP.NET Core 7 is an important part of Microsoft's "cloud-first" version called  NET 7, which was presented in November. Which was introduced in November. It offers web developers a range of powerful new tools to create modern web applications. ASP.NET Core 7 is built on the .NET Core runtime and provides all the necessary resources to build state-of-the-art web user interfaces and reliable back-end services. The best part is that it supports Windows, Linux, and macOS operating systems, allowing developers to work across different platforms. You will find examples of code to help you get started with ASP.NET Core 7 in this article. To try out the code examples mentioned in this article, you will need to have Visual Studio 2022 installed on your computer. If you don't already have it, you can download Visual Studio 2022 from this link. Now, let's explore some of the exciting new features in ASP.NET C...