Handling IIS Error pages in Sitecore

Sitecore lets you direct errors, such as page not found, to other pages within Sitecore. This is good – it lets you have an error page with all your dynamic content (navigation menus, account details, etc).

You can patch this in with something like:

<?xml version="1.0"?>
<configuration xmlns:x="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<!-- Default: /sitecore/service/notfound.aspx -->
<setting name="ItemNotFoundUrl">
<x:attribute name="value" value="/errors/Item Not Found" />
</setting>
<!-- Default: /sitecore/service/nolayout.aspx -->
<setting name="LayoutNotFoundUrl">
<x:attribute name="value" value="/errors/Item Not Found" />
</setting>
<!-- Default: /sitecore/service/notfound.aspx -->
<setting name="LinkItemNotFoundUrl">
<x:attribute name="value" value="/errors/Item Not Found" />
</setting>
<!-- Default: /sitecore/service/noaccess.aspx -->
<setting name="NoAccessUrl">
<x:attribute name="value" value="/errors/No Access" />
</setting>
<!-- Default: /sitecore/service/error.aspx -->
<setting name="ErrorPage">
<x:attribute name="value" value="/errors/Error" />
</setting>
</settings>
</sitecore>
</configuration>

Great, job done, right?

Nope…  Continue reading “Handling IIS Error pages in Sitecore”

Advertisements
Handling IIS Error pages in Sitecore

Removing a service from the command line

When uninstalling Sitecore 9, sometimes you have to delete the services it creates in Windows by hand.

The command for this is:

sc delete [service name]

Service name can be found on the properties of the service. Don’t forget to delete them both.

Removing a service from the command line

Avoiding the IClientApiService

So, I’ve blogged previously about my problems with the IClientApiService on a Content Management (CM) server. See https://andrewwburns.com/2018/08/15/unable-to-resolve-service-for-type-sitecore-emailcampaign-cd-services-iclientapiservice-while-attempting-to-activate/

Well, I asked Sitecore support about it, and they gave a really helpful response:

// This should be injected rather than calling the ServiceLocator
IMessageBus automatedMessageBus = ServiceLocator.ServiceProvider.GetService<IMessageBus>()
AutomatedMessage automatedMessage = new AutomatedMessage()
{
ContactIdentifier = contactIdentifier,
MessageId = emailCampaignId
};
automatedMessageBus.Send(automatedMessage);

Their reasoning for this was:

It is not recommended to add the configuration on CM since:
1) It is not enough to add only the <configurator> section, since it has dependencies on other configuration sections.
2) The CustomServiceConfigurator may change in the next release and the functionality will stop working.

Fair enough, seems sensible, though I’m now slightly at a loss for what the IClientApiService is actually for. I’ve tried the code they’ve send across, and it sends email correctly (and yes, I used DI, rather than a ServiceLocator).

I’ve tested this code locally, and it works nicely; I haven’t yet had a chance to try it on a scaled environment. I also decompiled the relevant assemblies, and yes, behind the IClientApiService implementations it seems to use a MessageBus<AutomatedMessage> object, so this should be equivalent.

Avoiding the IClientApiService

“…is not valid datasource for master or user does not have permissions to access”

I got this error while looking at a customer’s system, and weirdly, all renderings that used datasources had stopped working.

Sadly, I don’t still have the full stack trace, but it turns out the problem was a mis-configured URL for the SOLR service. Sitecore uses content search to find the datasource for a component.

This fact was a new one for me!

I think our URL lacked a /, or /#/. We corrected it, and the error went away – and our datasourced renderings started working again.

I found a reference on StackExchange after the fact.

“…is not valid datasource for master or user does not have permissions to access”

Unable to resolve service for type ‘Sitecore.EmailCampaign.Cd.Services.IClientApiService’ while attempting to activate…

A colleague had this error occur while setting up a production system. Everything had been fine in development, but Dependency Injection seemed to be throwing a wobbly when it tried to load the service we’d written for adding/removing contacts from a subscription list.

Edit: I raised this problem with Sitecore and got a helpful response: https://andrewwburns.com/2018/08/17/avoiding-the-iclientapiservice/

Continue reading “Unable to resolve service for type ‘Sitecore.EmailCampaign.Cd.Services.IClientApiService’ while attempting to activate…”

Unable to resolve service for type ‘Sitecore.EmailCampaign.Cd.Services.IClientApiService’ while attempting to activate…

Rebuilding Core’s Link Database on Sitecore 9.0 Update 1 generates lots of errors

When rebuilding the Link Database for the Core database on Sitecore 9.0 Update 1 (XP0 configuration), I received 630 errors!

The Link Database rebuild continues, and appears to complete successfully. I didn’t see any problems arising from this, but 630 errors is quite a lot.

I was also able to replicate this on several different development systems for different customers. I even set up a new, unmodified Sitecore 9.0 Update 1 – XP0 instance locally, and replicated the problem. Each system shows 630 errors per Core’s Link Database rebuild. Rebuilding Master or Web databases does not cause this error.

It appears that the issue is to do with deserialising the layout field’s XML during Links Database rebuild. It seems some items must have a layout that is “:”.

I raised this with Sitecore and got a very quick response. Continue reading “Rebuilding Core’s Link Database on Sitecore 9.0 Update 1 generates lots of errors”

Rebuilding Core’s Link Database on Sitecore 9.0 Update 1 generates lots of errors

Glass, ForceRenderField, and the RenderField pipeline

I was recently doing some token replacement of field values using a processor that I was adding to the RenderField pipeline. The problem was, it wasn’t running in Glass. Debugging in Visual Studio, the pipeline was never hit. Standard Sitecore rendering of the field was fine, but Glass – nope. Continue reading “Glass, ForceRenderField, and the RenderField pipeline”

Glass, ForceRenderField, and the RenderField pipeline