Handling 404s in Sitecore

Sitecore lets you specify a page to use for ‘ItemNotFound’ errors in web.config, and it’s always good practice to have a pretty ‘page not found’ page:

<setting name="ItemNotFoundUrl" value="/404" />

However, Sitecore hasn’t always been the best for actually returning the right HTTP status code for the 404 page. It redirects (more on that later) your failed request to a specified page in Sitecore – but the serves that page correctly, including an HTTP 200 status. This is sad, as search engines don’t understand that the page actually hasn’t been found. Continue reading “Handling 404s in Sitecore”

Handling 404s in Sitecore

Don’t forget to set a machine key

When deploying Sitecore, especially if you’ve got multiple Content Delivery servers, don’t forget to set a <MachineKey> in your web.config file.

The MachineKey is used to encrypt and secure the page’s ViewState. By default, the .NET framework uses that machine’s own MachineKey, but should your view state get sent to another content delivery server with a different key, well, then the ViewState will be invalid. That’s something of a problem.  Continue reading “Don’t forget to set a machine key”

Don’t forget to set a machine key

Newly Published Sitecore Item doesn’t appear in Search

We have recently been doing a number of Sitecore upgrades. In one of them, we have upgraded the system from Sitecore 6.5 to 7.2. After the upgrade, newly published News items didn’t appear on their news page. This used search, and upon examination of the Lucene indexes, the new items didn’t exist in the index. Continue reading “Newly Published Sitecore Item doesn’t appear in Search”

Newly Published Sitecore Item doesn’t appear in Search

For Multiple Publishing Targets, Update IndexUpdateStrategies

Hat off to Kam Figy for his phenomenally useful post – “Have two web databases? Don’t forget the IndexUpdateStrategy“. The clue is in in the title – if you’ve got multiple publishing targets – so multiple web databases – you’ll need to specify a new (differently named) OnPublishEndAsync strategy (e.g. OnDeliveryPublishEndAsync). The standard one only applies to the Web database. Then reference that strategy.

Go read his post; it’s a good one.

For Multiple Publishing Targets, Update IndexUpdateStrategies

Check your app pool recycling before rebuilding indexes

So, I have been working on the upgrade of a very large Sitecore instance. As part of the upgrade, you have to rebuild the search indexes. This is a very time consuming process, so I was starting it at the end of the working day – but it kept failing. Continue reading “Check your app pool recycling before rebuilding indexes”

Check your app pool recycling before rebuilding indexes

Sitecore’s “Send Email Message” save action retains mail server settings

Today I faced an issue with Web Forms for Marketers (WFFM). We had taken a copy of a customer’s system and were trying to test some changes we’d made to it. This involved making sure that the system sent email correctly, and we wanted it to send them to a mail-trap, rather than sending them to actual users. However, when I tried to change the mail server settings, the forms of the system seemed to continue to try to use the customer’s live SMTP server. This was surprising. Continue reading “Sitecore’s “Send Email Message” save action retains mail server settings”

Sitecore’s “Send Email Message” save action retains mail server settings

Programmatically caching things in Sitecore

I’ve seen a number of Sitecore projects now that use the ASP.NET cache, and this bothers me slightly. Shouldn’t Sitecore – which does have it’s own caching – offer a way of caching itself? Perhaps with integration to things like ‘clear cache on publish’, etc.?

Well, it does, and Anders Laub describes it neatly in “How to create a custom cache in Sitecore“.  Continue reading “Programmatically caching things in Sitecore”

Programmatically caching things in Sitecore

Fix HTML tags in Single-line or Multi-line text fields

Between Sitecore 6.5 and Sitecore 6.6 Sitecore changed the way that Text Fields are rendered.They changed it so that text fields output was HTML Encoded. This is technically correct, and it’d be fair to call this a bug fix. It’s much safer to prevent users injecting HTML.

However, this is a problem for systems where users have put HTML content into those text fields, especially where you have thousands and thousands of pages.

For example, in a widget:
Example in a Sublayout

Or in a footer:
Example in Footer

Identifying where those fields contain such values could be … challenging. Instead, Martin English has written a nice processor for the RenderFields pipeline that should restore the old unencoded HTML output.

Fix HTML tags in Single-line or Multi-line text fields

Sitecore’s SearchHits.Slice(int) method seems to change in Sitecore 6.6

I am working on a Sitecore 6.6 upgrade (yes, I know that that is still pretty much obsolete) and I came across a weird bug that took an age to track down. This is more a reminder for myself than anything else.

The code for Lucene searches frequently used lines of the form:

Slice Capture

List<SearchHit> distinctHits = hits.Slice(0).Distinct(new SearchHitEqualityComparer()).ToList();

This always returned zero SearchHits. It seems that this is due to the call to ‘Slice(0)‘ bit. This does raise some questions… Continue reading “Sitecore’s SearchHits.Slice(int) method seems to change in Sitecore 6.6”

Sitecore’s SearchHits.Slice(int) method seems to change in Sitecore 6.6