Category Archives: General .NET

Issues related to general .NET and C# development

Manipulating XML Google Merchant Data using C# and LINQ

Receiving a Google Merchant Data feed (also known as a Google Product Feed) can be fairly easily manipulated on import time using a little C# and LINQ. The feed is basically a XML RSS 2.0 feed with some added properties … Continue reading

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

C# Azure TelemetryClient will leak memory if not implemented as a singleton

I noticed that my classic .net web application would leak memory after I implemented metrics for some background tasks. Further investigation showed that my MetricAggregationManager would not release its memory. Since one of the major changes was the implementation of … Continue reading

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

Remove duplicates from XML feed

Apparently XML isn’t dead yet, and today I received a Google Product Feed in the RSS 2.0 XML format. The feed was full of duplicates and my job is to remove them: As you can see, “Product 100” appears twice. … Continue reading

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

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 , , | 1 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

Sitecore Create/Read/Update/Delete/Copy/Move/Rename item – the beginners guide

New Sitecorians often ask the most trivial questions, and I am happy to answer them. This question popped up lately: How do you perform basic CRUD operations on your Sitecore items? Well, it’s easy: READ ITEM (GET ITEM): CREATE ITEM: … Continue reading

Posted in .net, c#, General .NET, Sitecore 5, Sitecore 6, Sitecore 7, Sitecore 8, Sitecore 9 | Tagged , | 1 Comment

Sitecore use global and environment variables in config files

The Sitecore config files are a complex machine and it requires a healthy mind to work with it. Fortunately Sitecore have implemented a few tricks to ease our pain. This article focuses on 2 parts: global variable replacement and environment … Continue reading

Posted in .net, General .NET, Sitecore 8, Sitecore 9 | Tagged , , , | 1 Comment

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the ‘await’ operator to the result of the call

This C# warning occurs if you call an async method from your non-async code. Imagine you have this imaginary async method: And you call the method from this imaginary non-async method: The compiler will warn you with the following message: … Continue reading

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

Sitecore Publish Items using the PublishManager

Sitecore have two entries to publishing: Create a new Publisher and call Publish() or PublishAsync() Use the Sitecore.Publishing.PublishManager You should use the PublishManager. Sitecore introduced the Publishing Service which is an optional external publisher that is much faster than the … Continue reading

Posted in .net, c#, General .NET, Sitecore 8, Sitecore 9 | Tagged , , | 2 Comments

ID or Id? Naming conventions in code

This topic is not as toxic than the tabs-vs-spaces or 2 vs 4 indents discussion, but it’s still something every coder I have met have an opinion about, no matter the programming language: Which is correct: OrderId OrderID Lets solve … Continue reading

Posted in General .NET | Tagged , , | 1 Comment