Output Caching With Dotnet 7

Output Caching middleware has introduced in .net 7 , that is used to apply caching in your application. It can be used in any .net core application like Minimal API, Web API with controllers, MVC, and Razor Page. But I am using controller APIs in this project.

What is Caching?

Caching is a process of temporarily storing frequently accessed data or resources in a faster and closer location to the user or application, with the goal of reducing the time and resources needed to retrieve that data from its original source. By keeping a copy of the data nearby, caching enables quicker access and improves the overall performance and responsiveness of applications.

[Read More]

JWT Authentication and Role Based Authorization in Dotnet Core

JWT Authentication in dotnet core

JWT

According to jwt.io JSON Web Tokens are an open, industry standard RFC7519 method for representing claims securely between two parties.

When we create REST APIs, then we don’t want that any one can access those apis. REST APIs, will only be accessed by the authenticated user. We authenticate our user with the help of jwt.

How jwt works?

First, we give an authentication endpoint to user, where he/she puts credential, in return we give a jwt token to user which have an expiry date. To consume any protected resource, user need to pass jwt token on authorization header.

[Read More]

Create Sln File With Multiple Projects

Create Sln File With Multiple Projects

In this article we will learn how to create a .net core project with a Solution (sln file) that contains multiple projects. I know most you guys use visual studio for c# related stuff, but it would be benificial for person who likes to switch with vs code ocassionally, like me or who use linux and forced to use .net cli. Although if you are a new developer and have windows operating system, I will recommend visual studio, because it is the best possible IDE for c# development.

[Read More]

Api Versioning in Dotnet Core

Api versioning in .net core

Photo by Jan Loyde Cabrera at medium.com

When you are going to do some breaking changes in your apis, it is better to create a new version for that, so that user don’t freaked out. They still can use the older APIs and get ready for new changes. There are various way to create a versions of your APIs like

  1. Query string
  2. URL
  3. HTTP header

If you prefer video version then you can checkout this video with same content.

[Read More]

Write dapper effectively with generic methods

Dapper tutorial with dotnet core

Dapper is a micro ORM for database connectivity in dotnet and it’s been around for quite a while. It is loved by most of the developers because of its simplicity and performance.

Why dapper?

With the help of dapper you can quickly access the data without writing too much code. It performs very well because we directly write queries and executes them. Developers who loves to work with queries and for the projects, where performance really matters where you wants to write very optimized queries, dapper can be the good choice.

[Read More]

Serilog in .NET

serilog-in-dotnet

In your development journey you have faced so many runtime exceptions. You have handled that with try catch block. But in the runtime you never know where that error has happened and you have to trace that whole section with putting breakpoints. Sometime you have thought that I wish.. I would get notified whenever that exception occur. Then the logging frameworks comes in the play.

Although .net core comes with its own logging mechanism but it have very limited options for logging. With 3rd party logging framework or 3rd party logging library you have multiple options, like you can log into files, console, database and so on.

[Read More]