There are some common mistakes that one can see over and over again while reading an asynchronous code base. This mistakes range from egregious mistakes that can halt the whole process. To mistakes that create confusion and semantically incorrect code. So in this post, I’ll gather these common mistakes into a post with the top …
Asp.Net Core
Asp.Net Core API: Patch Method Without Using JsonPatchDocument
Some time ago, I needed to implement a mechanism for an API to update an entity without using JsonPatchDocument. The reason was that the user of the API didn’t want to necessarily use JSON to use the patch method. But user might want to use XML, Message Pack or any other format. What I needed …
When Should You Use Task.Delay
This post is about how Task.Delay can be used in different scenarios. Generally speaking we use Task.Delay to wait for specific amount of time in asynchronous fashion. I’m also going to explain why do we need to sometimes mimic this kind of behaviors. What Task.Delay Does? In some scenarios, we need to wait for specific …
When to Use Async and Await and How it Works
In my last post, I discussed why asynchronous and parallel programming is becoming increasingly more important. We also saw the difference between asynchronous and parallel programming. In this post we’re going to see when asynchronous programming should be used. I’ll also show you how previous API for asynchronous programming worked. So we can see how …
Concurrency Vs Parallelism
Recently I decided to start gaining more knowledge in concurrency and Parallelism in programming and go deeper as I progress in my study. I intend to share my knowledge in this areas through a series of posts that I’ll publish each month. I’ll go deeper and deeper with each post into the subject of asynchronous …
.Net Exceptions Best Practices
Exception is one of those constructs that is easy to misuse. This might include not throwing exception when one should or catching the exception without a good reason. Also there is the problem of throwing the wrong exception which not only doesn’t help us, but can confuse us. On the other hand there is the …
Asp.Net Core 2 Logging With Serilog And Microsoft SQL Server Sink
In this post, I’m going to describe how we can configure Serilog with Asp.Net Core 2 web and Api projects. I also configure Serilog to work with SQL Server database to store the logging information. Then I’ll write an extension method and use the built-in exception handling middleware to log exceptions in production environments. What …
Policy-based Authorization Using Asp.Net Core 2 And IdentityServer4
In my previous post, I’ve discussed how we can implement policy-based authorization to secure our API using JWT. But that wasn’t what I end-up using in production. Partly because the built-in mechanism of Asp.Net Core with JWT is not as powerful as IdentityServer4. Also I needed the single sign-on feature of IdentityServer4. There are two …
Policy-based Authorization Using Asp.Net Core 2 And Json Web Token (JWT)
I’ve been tinkering with different options to secure the API endpoint of one of my Asp.Net Core apps. What I end up using was IdentityServer4, primarily because my app needed Single sign-on too. But for straightforward scenarios, I think IdentityServer4 is an overkill. That’s where JWT comes in, so in this post, I’m going to …
Asp.Net Core Model Binding: Controlling The Binding Source
Asp.Net Core Model Binding has a set of attributes that gives us the ability to control from what source we want to receive the binding data. In this post I’m going to go through these attributes and show how and when you can use them. Default Model Binder Behavior The default behavior of model binder …