Quantcast
Channel: briancaos – Brian Pedersen's Sitecore and .NET Blog
Browsing all 276 articles
Browse latest View live

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...

View Article


Image may be NSFW.
Clik here to view.

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...

View Article


Image may be NSFW.
Clik here to view.

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...

View Article

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...

View Article

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...

View Article


Image may be NSFW.
Clik here to view.

C# .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 Article

C# 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 Article

Simple 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 Article


C# 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 Article


Sitecore 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 Article

Image may be NSFW.
Clik here to view.

Handling “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

Image may be NSFW.
Clik here to view.

Sitecore ComputedIndexField extends your SOLR index

The Sitecore SOLR index is your quick access to Sitecore content. And you can extend this access by adding computed index fields. This is a way of enriching your searches with content that is not part...

View Article

C# Remove specific Querystring parameters from URL

These 2 extension methods will remove specific query string parameters from an URL in a safe manner. METHOD #1: SPECIFY THE PARAMETERS THAT SHOULD GO (NEGATIVE LIST): using System; using System.Linq;...

View Article


Image may be NSFW.
Clik here to view.

Sitecore KeepLockAfterSave – Configuring Security Policies Per-Role Based

Now here is a nifty Sitecore trick. You have probably learned about the AutomaticLockOnSave feature that allows Sitecore to lock an item when it is saved. The feature is enabled or disabled using...

View Article

Image may be NSFW.
Clik here to view.

C# Using Dapper as your SQL framework in .NET Core

Dapper is a easy to use object mapper for .NET and .NET Core, an it can be used a variety of ways. I use Dapper instead of Entity Framework because it makes my code less complex. BASICS OF DAPPER: THE...

View Article


Image may be NSFW.
Clik here to view.

.NET Core QueueMessage JSON to Typed Object. Using Azure.Storage.Queues

The documentation around .NET QueueMessage is a little fuzzy so depending on the version of your NuGet libraries might differ in properties. This article uses the Azure.Storage.Queues,...

View Article

Read from Azure Queue with .NET Core

The documentation around Azure Queues and .NET Core is a little fuzzy, as the approach have changed slightly over the last updates. Previously you had a shared Storage Account NuGet Package that gave...

View Article


Read and Write blob file from Microsoft Azure Storage with .NET Core

The documentation on the Azure Storage Blobs are a little fuzzy, as the NuGet packages and the approach have changed over time. The latest NuGet Package is now called: Azure.Storage.Blobs The concept...

View Article

C# Remove Duplicates from List with LINQ

C# LINQ do have a Distinct() method that works on simple types: // An string with non-unique elements string s = "a|b|c|d|a"; // Split the list and take the distinctive elements var distinctList =...

View Article

Image may be NSFW.
Clik here to view.

Create a custom Azure Dashboard Tile Using an Azure Function and Markdown Format

The tiles on an Azure Dashboard will only display data from Azure itself. So if you have data from the outside, like a database, you need to make a few workarounds. Tiles of an Azure Dashboard Now,...

View Article
Browsing all 276 articles
Browse latest View live