Category: Tips
-
Switch the Context Item
Some times you’ll come across some code which relies on reading the Sitecore.Context.Item and there is no way for you to change this. This can occur when calling some standard Sitecore pipelines, some custom code which has been inherited without the source etc. Well, Sitecore API to the rescue. Introducing the ContextItemSwitcher I am not…
-
Sitecore Analytics: Display content by relevance using profile cards
For this post to make sense I will need to create a user story. I will not try to create a standard scenario instead I will create a scenario that is easy to understand and easily applicable to this post. The problem we want to solve is to present some content to the user that…
-
Ensuring roles in Sitecore
Roles are easy to create in Sitecore but sometimes you might want to ensure that some specific roles always exists. Not a very common scenario but nonetheless it happens. Once upon a time we needed to be able to ensure that a long list of specific roles always existed on the production instance otherwise some…
-
Lucene: Indexing DateTime from Sitecore and querying date ranges
The title should be self explanatory. I need to index some sitecore items that represent some entities that are valid to the public between certain dates. The sitecore fields are date time fields looking like this. I needed a solution for indexing these values in a way that i can do range queries on them.…
-
Creating a custom pipeline in Sitecore
Pipelines are one of the most essential parts of Sitecore and creating your own custom pipeline in Sitecore makes your code extremely flexible for both you and others. It is extremely easy to create and run a custom pipeline as this post will show. Defining the pipeline A pipeline consist is a set of processor…
-
Preview deletes the .aspxauth cookie
I’ve been working a bit on an extremely weird support case the last couple of days. When the editors on a site clicked on preview from either the content editor or the page editor then the page ended up in a redirect loop. Who stole my cookie? Using Fiddler I quickly noticed that the .ASPXAUTH…
-
Creating a customHandler in Sitecore
Sometimes you would like all requests to a specific path and below to be handled by a specific generic handler. For example in the same manner as the mediaHandler works in Sitecore. Setting up a customHandler in Sitecore Configuring a normal httpHandler in .NET is easy, you simply add entries in the web.config depending on…
-
How to hijack Sitecore instance using only cookie information
Or how to scare any project manager, sales guy or customer into choosing to run their site on https. This is not going to be a lesson in how to obtain cookie information sent over a network. You can find a ton of youtube videos and other resources on how to setup a tool like…
-
A note about Sitecore pipelines
My two previous posts both contained implementations of custom processors for the httpRequestBegin pipeline. Just a quick explanation about their structure and some absolute best practices when implementing your own Sitecore pipeline processors. Check and exit fast Since the httpRequestBegin pipeline handles all requests it is extremely important to check the context for validity before continuing…
-
HTTPS in Sitecore
I would always recommend running all production site cms’ using security on the transport layer (https). Sitecore or no Sitecore, it is not safe to first send username and password unencrypted and then following having an insecure session cookie for the authentication information. This applies for both extranet users and the backend administrators. A basic…