Author Archives: briancaos

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.

Write 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 to lock a shared resource. This article … Continue reading

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

HttpClient 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 retry logic is called policies, and … Continue reading

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

Azure 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 starting … Continue reading

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

Programmatically 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 search query language). One cool … Continue reading

Posted in General .NET | 1 Comment

Sitecore 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 SECURITY SET ON THE TARGETITEM Items where … Continue reading

Posted in .net, c#, General .NET, Sitecore, Sitecore 6, Sitecore 7, Sitecore 8, Sitecore 9 | Tagged , , , , | Leave a comment

Filtering 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 can run wild if you are not … Continue reading

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

Add 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 attached to that client. In a previous post I showed how to … Continue reading

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

Sending JSON with .NET Core QueueClient.SendMessageAsync

You need to Base64 encode JSON serialized strings before adding them to a queue Continue reading

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

Sitecore Publish item when moved or dragged using uiMoveItems and uiDragItemTo pipelines

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. This technique really applies to whatever you … Continue reading

Posted in c#, Sitecore 6, Sitecore 7, Sitecore 8, Sitecore 9 | Tagged , , , | Leave a comment

Run 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 imaginary method … Continue reading

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