Using translation API with Sitecore ASP .NET Core Rendering Host

Currently there is no client side API implementation done of the Sitecore dictionary translation API in the official Sitecore ASP .NET Core SDK, therefore I decided to implement a PoC. After googling a bit I found, Sitecore already provides an API endpoint to resolve dictionary items and it’s already implemented in the JSS clients. So based on this documentation I found the API endpoint on my local Sitecore CM instance, which is

/sitecore/api/jss/dictionary/<site>/<language>/?sc_apikey=<apikey>

The response of this endpoint is the following:

{
"lang": "en",
"app": "Discovering.Sitecore101",
"phrases": {
"label1": "label 1",
"label2": "label 2"
}
}
Continue reading “Using translation API with Sitecore ASP .NET Core Rendering Host”

Sitecore Publishing Web Hook – Sitecore Rendering Host output caching PoC update

Sitecore 10.1 released a few weeks ago and one of the new features is the Publishing Web Hook. The main reason why this is introduced is to able to easily update JAMstack apps on publish. Official step-by-step guide for Vercel deployment can be found on the official Sitecore JSS documentation site, here.

Continue reading “Sitecore Publishing Web Hook – Sitecore Rendering Host output caching PoC update”

Using Sitecore configuration API from Service Configurator

OR when you are facing with the following exception:

[LockRecursionException: A read lock may not be acquired with the write lock held in this mode.]
System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout) +1347
System.Threading.ReaderWriterLockSlim.TryEnterReadLock(TimeoutTracker timeout) +44
Sitecore.DependencyInjection.ServiceLocator.get_ServiceProvider() +176
Sitecore.Configuration.<>c.<.cctor>b__360_0() +9
System.Lazy`1.CreateValue() +734
System.Lazy`1.LazyInitValue() +189
Sitecore.Configuration.Settings.GetSetting(String name) +48
Continue reading “Using Sitecore configuration API from Service Configurator”

Discovering Sitecore ASP .NET Core SDK – Datasource Item Children Resolver

TL;DR

namespace Discovering.Sitecore10.Models
{
public class ChildrenBlockModel
{
[SitecoreComponentField(Name = "items")]
public IEnumerable<ItemLinkField<ContentBlockModel>> Children { get; set; }
}
public class ContentBlockModel
{
[SitecoreComponentField]
public TextField Title { get; set; }
}
}

Longer interpretation

I wanted to play around a bit with different Contents Resolvers. The default resolvers are the following under the /sitecore/system/Modules/Layout Service/Rendering Contents Resolvers item:

  • Context Item Children Resolver
  • Context Item Resolver
  • Datasource Item Children Resolver
  • Datasource Resolver
  • Folder Filter Resolver
  • Sitecore Forms Resolver
Continue reading “Discovering Sitecore ASP .NET Core SDK – Datasource Item Children Resolver”

Sitecore ASP .NET Core SDK output caching PoC

One of my first question about Sitecore ASP .NET Core SDK was that, is there any built in rendering side caching mechanism implemented already?

This is in consideration in the roadmap, we are looking at ways to expose publishing events to the rendering host to enable this.

Nick Wesselman

Meanwhile, I thought I implement something simple to achieve this. The basic idea is to open and endpoint in the ASP .NET Core rendering host which will “clear” the cache. This endpoint can be called by the Sitecore CM while publishing. This is not a production ready implementation but could be a good starting point for you. So let’s start with it!

Continue reading “Sitecore ASP .NET Core SDK output caching PoC”

ASP.NET Core MVC – Start session extension modularized

I got a feature request that I should store something on session start. In the old ASP.NET Framework world it was easy because we had Globbal.asax.cs and its Session_Start event. The original answer to this question is here. But, as I prefer overengineering modular architecture and Sitecore Helix principles I wanted to make it extensible without touching this Foundation piece of code. As you probably know we have Startup.cs instead of Global.asax.cs and DistributedSessionStore. To extend the Create method of the DistributedSessionStore you can just simply inherit from its interface ISessionStore.

Continue reading “ASP.NET Core MVC – Start session extension modularized”

Diagnose Solr connectivity issues on production

This blog post is for you if you find the following warnings in Sitecore logs:

  • [Index=<indexname>] Crawling Paused
  • [Index=<indexname>] Synchronous Indexing Strategy is disabled while indexing is paused.
  • IndexingStateSwitcher: Indexing is not resumed since indexes have not been initialized yet…
  • Exception: SolrNet.Exceptions.SolrConnectionException, Message: Unable to connect to the remote server
Continue reading “Diagnose Solr connectivity issues on production”