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:...
View ArticleSitecore Item Clones is only a thing in the master database
The Sitecore item cloning is a technique in which you can create a copy of an item that inherits the field values of the original items. In the latest versions of Sitecore (at least from 9.0 and...
View ArticleAzure Functions CRON expressions
When creating Microsoft Azure Functions, you can have a timer that triggers your function. The time for when the function should run is specified in a CRON expression: Microsoft Azure CRON Expression...
View ArticleCalling Azure Functions from JavaScript – The CORS configuration
You cannot call Azure Functions from JavaScript unless you configure the CORS settings for your Function Apps: Azure Functions CORS Settings This is because Microsoft have by default enabled CORS and...
View ArticleChange 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: public static...
View Article200 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...
View ArticleSitecore remove “Job started” and “Job ended” from log files
In large Sitecore installations with many background tasks you will find the following log lines over and over again: ManagedPoolThread #1 10:26:05 INFO Job started: xxxxx ManagedPoolThread #5 10:26:05...
View ArticleSitecore logging – Create new log file every day
Sitecore have since forever used Log4Net as it’s logging platform. Log4Net is nicely extensible and can be configured to log in many ways. As per default, Sitecore is configured to start writing to a...
View ArticleSitecore use Application Insights Metrics and Telemetry
Although Sitecore have an integration for Application Insights (which is part of Azure Monitor), you can implement the TelemetryClient yourself. This is useful if you wish to log Metrics or Trace your...
View ArticleIdentityServer 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...
View ArticleSitecore CTRL+S fires item:saving event twice
If you have ever tried to implement your own Sitecore item:saving or item:saved event handlers, or have tried to extend the SaveUI pipeline, you might have noticed that the events gets fired twice if...
View ArticleWhich 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...
View ArticleNewtonsoft 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: { "sub": "55568182-9273-4c6f-8d61-6555f7f02551", "role": "role001" } But if there is more than...
View ArticleHttpClient 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...
View ArticleID 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...
View ArticleSitecore publish certain items on save
My Sitecore solution have some items, where changes to certain fields are so critical that they need to be published immediately. So when my user presses the Save button, I will open a popup dialog,...
View ArticleSitecore 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...
View Article.NET Core MVC Web API – control DateTime format in JSON output using...
When creating API’s with .NET Core MVC, you can control the JSON output by adding JsonOptions to the controllers: public void ConfigureServices(IServiceCollection services) { ... ......
View ArticleBecause this call is not awaited, execution of the current method continues...
This C# warning occurs if you call an async method from your non-async code. Imagine you have this imaginary async method: internal class QueueRepository { public async Task AddMessage<T>(T...
View Article.NET Core API and CORS – allow POST from Javascript using...
After hours of debugging, I finally managed to apply CORS correctly to my .NET Core 3.0 Application. Like so many other before me, I used this article as reference: Enable Cross-Origin Requests (CORS)...
View Article