I am trying to change layout in SiteCore 8.0 (update 3) for all my pages from code behind. I am using layout resolver pipeline for it. i can debug & see changed path, but cannot get updated layout on UI. I have seen various post by googling, who are doing same thing but those are quite old (older then 2-3 yrs).
below is my layout resolver pipeline code
public class LayoutResolver : HttpRequestProcessor
{
public LayoutResolver()
{
System.Diagnostics.Trace.WriteLine("PipeLine: ctor() has been called");
}
/// <summary>
/// Gets the layout for the page
/// </summary>
/// <param name="args"></param>
public override void Process(HttpRequestArgs args)
{
System.Diagnostics.Trace.WriteLine("PipeLine: This is atleast called");
Assert.ArgumentNotNull(args, "args");
if (!CanProcess())
{
return;
}
Context.Page.FilePath = "/Views/Shared/BusinessLayout_Two.cshtml";
}
private static bool CanProcess()
{
return Context.Database != null
&& !IsCore(Context.Database);
}
private static bool IsCore(Database database)
{
return database.Name == Constants.CoreDatabaseName;
}
}
EDIT : showconfig.config show my resolver register in config. SiteCoreSample.Helpers.LayoutResolver is my resolver.
<processor type="Sitecore.Pipelines.HttpRequest.LayoutResolver, Sitecore.Kernel"/>
<processor type="SiteCoreSample.Helpers.LayoutResolver, SiteCoreSample" patch:source="Sitecore.Mvc.config"/>
<processor type="Sitecore.Mvc.Pipelines.HttpRequest.TransferMvcLayout, Sitecore.Mvc" patch:source="Sitecore.Mvc.config"/>
<processor type="Sitecore.Mvc.Pipelines.HttpRequest.TransferControllerRequest, Sitecore.Mvc" patch:source="Sitecore.Mvc.config"/>
<processor type="Sitecore.ExperienceEditor.Pipelines.HttpRequest.CheckDevice, Sitecore.ExperienceEditor" patch:source="Sitecore.ExperienceEditor.config"/>
<processor type="Sitecore.Pipelines.HttpRequest.PageEditorHandleNoLayout, Sitecore.ExperienceEditor" patch:source="Sitecore.ExperienceEditor.config"/>
<processor type="Sitecore.ExperienceExplorer.Business.Pipelines.HttpRequest.ExecuteRequest, Sitecore.ExperienceExplorer.Business" patch:source="Sitecore.ExperienceExplorer.config"/>
