One of the most comment approaches is using httpRequestBegin
pipeline. You should be aware that this pipeline is called not only for pages though.
If you use mvc, you can use mvc.requestBegin
pipeline
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<mvc.requestBegin>
<processor type="MyAssembly.MyNamespace.MyProcessor, MyAssembly"
patch:after="processor[@type='Sitecore.Mvc.Analytics.Pipelines.MvcEvents.RequestBegin.StartTracking, Sitecore.Mvc.Analytics']"
resolve="true">
</processor>
</mvc.requestBegin>
</pipelines>
</sitecore>
</configuration>
public class MyProcessor : RequestBeginProcessor
{
public override void Process(RequestBeginArgs args)
{
}
}
EDIT
If you want to call a Controller
Action
on every single page, add code like below to cshtml file of your Layout
:
Html.Sitecore().Controller("Controller Name", "Controller Action")