Category Archives: .NET Core

HttpClient retry mechanism with .NET Core, Polly and IHttpClientFactory

A lot of HttpClient errors are temporary and is caused by server overload, temporary nerwork timeouts and generic gliches in the Matrix. These scenarios can be dealt with using a retry pattern. In .NET Core, the most common retry library … Continue reading

Posted in .NET Core, General .NET | Tagged , , | Leave a comment

.NET Core Worker Services with Application Insights and Serilog

The .NET Core Worker service is yet another tool in the .NET toolbox. They are perfect for background processing like reading from a queue or making health checks. They are cross-platform (of course) and they can run on docker containers, … Continue reading

Posted in .net, .NET Core, c# | Tagged , , , | Leave a comment

System.DllNotFoundException: Unable to load DLL ‘sni.dll’ or one of its dependencies: The specified module could n ot be found. (0x8007007E)

This message happens when deploying my .NET Core 3.1 application to production (when compiling the code to an .exe file), but not when running the application locally. It turns out, that Dapper is missing a reference to System.Data.SqlClient. Adding the … Continue reading

Posted in .net, .NET Core, c# | Tagged , , | Leave a comment

C# Get expiry timestamp from JWT token

JWT tokens (or Json Web Tokens) are an open-standard the defines a way to transmit information between 2 parties in a secure manner. Identity Server 4 uses JWT as a security token. These tokens have an expiry timestamp, and if … Continue reading

Posted in .net, .NET Core, c#, General .NET, Microsoft Azure | Tagged , , , , | Leave a comment

Application Insights not working in .NET Core Console Application – Remember to flush the TelemetryClient

My .NET Core console application did not write to my Application Insights instance. Well, it did, but only sometimes. Writing to Application Insights is done asynchronously, usually every 30 seconds or 500 items. This means that you need to give … Continue reading

Posted in .NET Core, Microsoft Azure | Tagged , , | Leave a comment

Azure App Configuration – Getting the connection string from appsettings.json

Azure App Configuration is a services that provides a central place to manage application settings, and it provides cool features like feature flags and auto refresh of settings when they are changed. To access Azure App Configuration from your .NET … Continue reading

Posted in .NET Core, c#, Microsoft Azure | Tagged , , , | Leave a comment

Command line parameters in .NET Core Console Applications

When implementing .NET Core console applications, you can extract the command line parameters from the void Main(string[] args) method, but it can be a little tedious to do so. To help with the parsing, Microsoft used to maintain the Microsoft.Extensions.CommandLineUtils, … Continue reading

Posted in .NET Core, c# | Tagged , | Leave a comment

.NET Core Api – Catch exceptions using a middleware

In .NET Core, we are starting to get used to the fact that nothing comes for free, and in the world of ultimate freedom of choice, every feature needs to be implemented by us. This includes error handling. In a … Continue reading

Posted in .NET Core, c#, Microsoft Azure | Tagged , , , | 3 Comments

.NET Core Catch Model Binding Exceptions

In .NET Core, if you create an API project, and you have an controller receiving an object you defined yourself, the controller will not be called if you use the wrong model, or if the model is not in a … Continue reading

Posted in .NET Core, c#, Microsoft Azure | Tagged , , | 1 Comment

ASP.Net Core API – “‘s’ is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.”

If you create an ASP.Net Core API Controller, and you wish to create an endpoint that can accept any string, you would expect this to be correct: But this endpoint will only accept strings in quotes, so posting string will … Continue reading

Posted in .NET Core, c# | Tagged , , | Leave a comment