Tag: Owin

This is a rule of thumb in Sitecore 9: Do not change global.asax. There are other ways to run a piece of code at the start of the Sitecore 9.

Until now I have used 2 ways in Sitecore 9 to run a piece of code at the start of the solution. In similar manner you can do it in Sitecore 8 as well.

#1 Using Sitecore Owin middleware.

With release of Sitecore 9, Sitecore decided to embed a OWIN module and with that there are a couple of pipelines that can be used.

What’s OWIN Middleware?

It stands for Open Web Interface for .Net. It is a new standardized interface between web servers and applications. It stands as a middleware to be used in a pipeline to handle requests and associated responses. OWIN provides a decoupling layer that allows two frameworks with disparate object models to be used together.

Sitecore 9 has implemented the OWIN Pipeline directly into the core platform and with that we can integrate external identity provider logins and no only.

Also, you can write your own implementation using OWIN, but will give you a proper example in my next article that is touching this topic and how to have custom authentication for your Sitecore Web Api.

In Sitecore 8 you can use module Sitecore-Owin to add OWIN support to your solution. Works quite well, as I have already used it to customize the Sitecore SignalR module.

#2 Using Initialize Pipeline in Sitecore.

This functionality was also available in Sitecore 8, in case you were not aware of that. This is used to start some functionality at Sitecore application start-up.

In a clean web application it possible to use global.asax, but Sitecore decided some time ago (not sure with what version exactly) to make globas.asax private. Instead you need to use the initialize pipeline. The initialize pipeline is started at the application start. Initialize pipeline is defined in Sitecore.config.
In order to use initialize pipeline it’s needed to created a new include config file with the new processor.