Server-side, client-side, code snippets, scripts, automation, best practices, proven approaches, tips & tricks...

Strongly typed configuration sections with options pattern in ASP.NET Core

Loading configuration values directly to classes and use them in the runtime
Configuration is probably the most essential part of every application, yet we do not give much attention to it during application design and development. .NET Core has quite nice way to store configurations (usually JSON files) and already built-in extensions to access configuration values and directly cast them to a specific type...read more

Unit testing repositories in ASP.NET Core with xUnit and Moq

Mocking UserManager RoleManager and DbContext in unit tests in .NET Core
Unit testing is an important part for maintaining code quality and what is the most important thing, avoiding bugs in production. This is one of the reasons why unit tests and high code coverage is desired as a part of the project and as a part of the build process since you can detect potential bugs and issues during the build process when unit tests are executed...read more

Mixed model binding in ASP.NET Core using custom model binders

IModelBinder interface implementations usage for multiple source model binding
Patterns, conventions and standards are invented and enforced in order to make coding easier and more understandable for the developers, but in some cases certain patterns and conventions do not couple so easily and you have to rely on more on the actual technology you are using in order to overcome these complications. One of the cases this happens is using CQRS, especially commands and REST. Although commands give clear separation of intention of some action, at the same time commands are especially tough to handle in soma cases because of their immutability...read more

Cloning Windows Virtual Machine in Azure without having to stop it

Zero downtime cloning of Virtual Machine in Azure using PowerShell
Creating a copy of an existing Virtual Machine on Azure is not really that much straight forward as you might think. The proper way as described in the documentation is to "generalize" Virtual Machine which puts it into a state where it can be used as a template for creating new Virtual Machines. Unfortunately this way of creating a clone of VM on Azure makes the source VM inaccessible...read more

Deploying .NET Core WebJobs to Azure using Azure Build Pipeline

Using Azure Build and Release pipeline to deploy WebJob to a WebApp instance
Azure WebJobs are a great way to run background processes for your Web application on hosted on Azure WebApp. Althought Microsoft does not yet provide Visual Studio project templates for .NET Core (it only has built in project template for .NET framework 4.x) it is still possible to develop WebJob using .NET Core and run in on a WebApp...read more

Using dispatcher class to resolve CQRS commands and queries in ASP.NET Core

Injecting dispatcher class instead of multiple commands and queries in controller constructor
Recently I wrote an article about Automatic CQRS handler registration in ASP.NET Core with reflection in order to reduce number of lines for registering command and query to IOC container in ASP.NET Core. However, this solution does reduce lines for service registration in the startup, you still need to add all command and query handlers as parameters to the controller constructor. ...read more

Automatic CQRS handler registration in ASP.NET Core with reflection

Registering all query and command handlers in your CQRS implementation in ASP.NET Core
Command Query Responsibility Segregation (CQRS) pattern is one of my favorite way of handling the Web API requests for a simple reason that is clearly separates reading and writing. Quite often at some stage of the project you will hit the performance bottlenecks which are most probably cause by the way you are reading ow writing your data. CQRS splits reading and writing so that you can independently use different persistence framework for reading and writing...read more

Displaying Azure DevOps build number in Swagger UI for ASP.NET Core

How to add and show Azure DevOps build number in ASP.NET Core project and Swagger UI
Swagger is a great way to document you REST API endpoints and reduce the need for communication, item spent and the cost for supporting the consumers of you APIs. Apart from providing the info about the endpoints, models, validation it can also display the data of the product...read more

Why you should not use Authorize attributes to protect your API endpoints

Protecting ASP.NET Core WebAPI without using Authorize attribute
Authentication is an essential component of pretty much any REST API. Most of the resources you expose through REST API services, unless they are protected inside intranet, need to be protected by some kind of authentication. This is pretty much clear and it is easy achieved by just simply decorating your controller actions or even whole controllers with Authorize or AllowAnonymous attributes. ...read more


read more

Umbraco CMS

read more


read more


read more