Category Archives: General .NET

Issues related to general .NET and C# development

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

C# HttpClient POST or PUT Json with content type application/json

The HttpClient is a nifty tool for getting and sending data to a URL, but it works differently from the old fashioned WebRequest class. The content type is added to the post data instead of added as a header parameter. … Continue reading

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

C# Newtonsoft serialize property that is an array and a string

IdentityServer4 has a strange way of returning roles. If there is only one role, the property is a string: But if there is more than one role, the property is an array of strings: If the property is a string, … Continue reading

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

Which of my old Sitecore posts are still valid in Sitecore 9?

I have been writing Sitecore blog posts since April 2006. The first ones were for Sitecore 4.2. Now, 13 years later, some of the old posts are still valid, while others are obsolete as the Sitecore API have changed. But … Continue reading

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

IdentityServer use IdentityModel to get user token and user info

Using IdentityServer have been made easier with the IdentityModel helper library. The library implements extension methods that maps the input and output to classes. GET ACCESS TOKEN: Use the PasswordTokenRequest and RequestPasswordTokenAsync to get the access token. replace your_domain, your_clientid … Continue reading

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

200 OK vs 202 Accepted – Whats the difference?

When working with Azure cloud services like Azure Logic Apps or Azure Automation (Runbooks), you often come across that service endpoints return 202 Accepted instead of 200 OK on success. But why do they do that, and what is the … Continue reading

Posted in General .NET | Leave a comment

Change date format using .NET Regular Expressions

You can use Regex.Replace to change the format of a date string. For example if your input string is YYYY/MM/DD but you need to change it to YYYY-MM-DD, you can use this small method: Regular expressions are unreadable as usual, … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , | 1 Comment

Sitecore start scheduled task manually

Sitecore scheduled tasks are background tasks running on a schedule. But never when you need it, especially when developing the tasks. You can trigger these tasks manually if you please. THE EASY WAY: INSTALL SITECORE POWERSHELL The Sitecore PowerShell module … Continue reading

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

Sitecore get Context from fully qualified URL

One of the basic Sitecore concepts is the concept of a context. The context is resolved from the HTTP Context to Sitecore and determines the database, language, user domain, content start item etc. The context is defined in the App_Config/Sitecore.config … Continue reading

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