C# Set local folder for .net Core Windows Services
When developing .NET Core Worker Services, you can allow the service to run as Windows Service: public static IHostBuilder CreateHostBuilder(string[] args) { var host = Host.CreateDefaultBuilder(args);...
View ArticleMethod not found: ‘Void...
I struggled with this error in my development environment: Method not found: ‘Void Sitecore.ContentSearch.Diagnostics.AbstractLog.SingleWarn(System.String, System.Exception)’. at...
View ArticleSitecore field level Security – give write access to members of a certain group
The Sitecore security model is pretty straight forward, but as everything security, it can become complicated. This goes for field level security. For a certain field, I wish to grant read access to...
View ArticleUsing full Lucene Query Syntax in Azure Search
The Azure Cognitive Search is the search engine in Microsoft Azure. You can search using a simple queries (default) which is good at doing full text searches, or you can use full syntax which is a...
View ArticleRun tasks in parallel using .NET Core, C# and async coding
If you have several tasks that can be run in parallel, but still need to wait for all the tasks to end, you can easily achieve this using the Task.WhenAll() method in .NET Core. Imagine you have this...
View ArticleSitecore Publish item when moved or dragged using uiMoveItems and...
Sometimes you have items that needs to be published immediately if moved to a new location in the content tree. Sitecore supports this – of course – via the uiMoveItems and uiDragItemTo pipelines. Move...
View ArticleSending JSON with .NET Core QueueClient.SendMessageAsync
In .NET Core, Microsoft.Azure.Storage.Queue have been replaced with Azure.Storage.Queues, and the CloudQueueMessage that you added using queue.AddMessageAsync() have been replaced with the simpler...
View ArticleAdd a UserAgent to the IHttpClientFactory in .NET Core
Using a IHttpClientFactory to create HttpClient connections have a number of advantages, as you can configure several httpclients on startup. Each client will be reused, including the properties...
View ArticleFiltering Application Insights telemetry using a ITelemetryProcessor
Application Insights is a wonderful tool. Especially when you have a microservice or multi-application environment and you need one place for all the logs and metrics. But it’s not free, and the costs...
View ArticleSitecore LinkField TargetItem is NULL – what’s wrong?
An ancient topic, that pops up once or twice every year. The TargetItem of Sitecore.Data.Links.LinkField returns NULL and you are CERTAIN that the item is published. What to do? CASE 1: THERE IS...
View ArticleProgrammatically create and delete Azure Cognitive Search Indexes from C# code
Azure Cognitive Search is the search engine of choice when using Microsoft Azure. It comes with the same search features as search engines like Elastic Search and SOLR Search (you can even use the SOLR...
View ArticleAzure Cognitive Search from .NET Core and C#
The Azure Cognitive Search engine is the search of choice in the Microsoft Azure. The search engine can be used in a myriad of ways and there are so many options that it can be difficult to find a...
View ArticleHttpClient retry on HTTP timeout with Polly and IHttpClientBuilder
The Polly retry library and the IHttpClientBuilder is a match made in heaven as it defines all the retry logic at startup. The actual HttpClient calls are therefore untouched by any retry code. The...
View ArticleWrite to file from multiple threads async with C# and .NET Core
There are several patterns on how to allow multiple threads to write to the same file. the ReaderWriterLock class is invented for this purpose. Another classic is using semaphors and the lock statement...
View ArticleC# .NET Core Solr Search – Read from a Solr index
.NET Core has excellent support for doing searches in the Solr search engine. The search language is not always logical, but the search itself is manageable. Here’s a quick tutorial on how to get...
View ArticleC# get results from Task.WhenAll
The C# method Task.WhenAll can run a bunch of async methods in parallel and returns when every one finished. But how do you collect the return values? Imagine that you have this pseudo-async-method:...
View ArticleSimple C# MemoryCache implementation – Understand the SizeLimit property
The .NET Core IMemoryCache is probably the simplest cache there is, and it is very easy to use, once you get your head around the weird SizeLimit property. Especially when using the nice extension...
View ArticleC# Newtonsoft camelCasing the serialized JSON output
JSON love to be camelCased, while the C# Model class hates it. This comes down to coding style, which is – among developers – taken more seriously than politics and religion. But fear not, with...
View ArticleSitecore AccessResultCache cache is cleared by...
Are you getting a lot of these messages in your Sitecore log: 6052 2021:03:25 05:23:12 WARN AccessResultCache cache is cleared by...
View ArticleHandling “415 Unsupported Media Type” in .NET Core API
The default content type for .NET Core API’s is application/json. So if the content-type is left out, or another content type is used, you will get a “415 Unsupported Media Type”: 415 Unsupported...
View Article