WebLog

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

Ignoring properties from controller action model in Swagger using JsonIgnore

Excluding properties from Swagger in controller action input model using Newtonsoft.Json package
 
0
While designing the REST API, quite often you may find yourself in a situation where the data can be provided from multiple sources, like route, query string or POST/PUT payload. While that might not be a big problem, it may force you to redesign your models and most likely you will end up with keeping your original DTOs but then designing a new model in your application services layer just to have all your data from different sources in one place when you are passing it to the service method. Resolving multiple sources custom binding ...read more

Increase service resilience using Polly and retry pattern in ASP.NET Core

Retry pattern in ASP.NET Core with Polly
 
0
Whether you are doing micro-services or mid-size monolith applications that do not have to be too distributed, there is a big chance that you will depend on some external HTTP service. Whether it is REST, SOAP or any other type of the response, your application flow depends on it's response. Sure using queues and event-based communication between services or components will definitely increase the resilience of the application and make more error-proof, it adds additional complexity to the whole solution and sometimes that can be an overhead depending on the application type or the infrastructure you might be limited with. ...read more

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

Loading configuration values directly to classes and use them in the runtime
 
0
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
 
0
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
 
0
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
 
0
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
 
0
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
 
0
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
0
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

JavaScript

read more

Umbraco CMS

read more

.NET

read more

SQL/T-SQL

read more