Archived articles

Archive for May 2018

Redis health check in ASP.NET Core WebApi
Checking availability of distributed Redis cache instances in ASP.NET Core WebApi
0
Even before popularity of micro service approach, for even monolithic applications you needed to have health-checks (Google Compute Engine) or health-probes (Microsoft Azure) for load balancing. Basically in load balancing scenario, these endpoints are used to tell load balancer whether instance can handle requests or not...read more
Using strongly typed objects with IDistributedCache instead of byte arrays
An easy way to cache any object to distributed cache store using .NET Core
0
Saving an object to distributed cache store in .NET Core requires your object to be serialized to byte array in order for SetAsync method on Microsoft.Extensions.Caching.Distributed.IDistributedCache interface implemented instance to save your object to the injected cache store instance. This means that what ever instance you have, you need to serialize it first to byte array. Similar, just reversed process applies for the process of reading an object from the distributed cache store. ...read more
Seeding data in Entity Framework Core from Visual Studio
Insert sample data from Visual Studio IDE with EF core
 
0
Unlike Entity Framework 6, EF Core and whole .NET Core relies on dependency injection. For example, configuration is expected to be injected from the calling assembly instead of being available at any time. This is one of the reasons Migrations in Code First approach do not work out of the box for EF Core...read more
Error handling in ASP.NET Core Web API
Generating the proper response for exceptions in ASP.NET Core WepApi
0
Both Web API in .NET 4.5 and later and Web API in ASP.NET CORE have great error handling support out of the box. You can specify you global handler and control your response to a client when exception happens. ...read more
SETNX with TTL in .NET using StackExchange.Redis
Set key if it does not exist in redis with expiry using StackExchange.Redis
0
Recently I needed to set redis key if it is not present with specific expiry time to use it as some logical flag. I knew tat you can use SETNX command for this but did not have any info how to set the expiry time. After some time going through redis documentation and articles found online I found a SET method overload for the redis-cli. ...read more
Monitoring DOM changes with JavaScript
Handling DOM changes with plain JavaScript
0
If you are dealing with pure JavaScript without using any library, you probably want to trigger your custom actions on some element event. This is easily done with addEventListener which is in general supported by all now days browsers. ...read more
Reading JSON data in T-SQL on SQL Server
Extracting values from JSON string on SQL Server using T-SQL
0
JSON is the most commonly used data fromat nowdays. It is lighter than XML, more readable and it's sindax complies with most OOP C-Like lnguages such as Java, JavaScript and C#. There is not really many downsides of using JSON, so that is one of the rasons everyone is using it in one way or another. ...read more
Generic string to primitive type converter in C#
Converting string data to any primitive type in .NET and .NET Core
0
Often case when you need to convert String to a different type which is most of the time a primitive type in C# is when you are reading values from configuration. In both .NET and .NET Core, reading from configuration return plain String value...read more

.NET

read more

JavaScript

read more

SQL/T-SQL

read more

Umbraco CMS

read more