Skip to main content
added 173 characters in body
Source Link
ckhanna
  • 3.7k
  • 1
  • 1
  • 12

Strip language is set inside the preprocessRequest pipeline which runs before the httpRequestBegin pipeline in which site context is set. Hence in order to obtain site context inside the custom processor created in the preprocessRequest pipeline using below code snippet.

using Sitecore.Pipelines.PreprocessRequest;
using Sitecore.Sites;
using Sitecore.Web;
using System.Linq;

public class CustomStripLanguage : StripLanguage
{
  public override void Process(PreprocessRequestArgs args)
  {
     var hostName = args.HttpContext.Request.Url.Host;
     SiteInfo site = SiteContextFactory.Sites
                .Where(s => s.RootPath != "" & s.HostName.Contains(hostName))
                .FirstOrDefault();
     if(site != null)
     {
        SiteContext contextSite =  SiteContextFactory.GetSiteContext(site.Name);
        // Based on the site context you can decide whether to strip language or not
        if(contextSite.Properties["StripLanguage"] == "false"){
           return;
        }
     }
     base.Process(args);
   }
}

Using above way, you should be successfully able to fetch site name inside preprocessRequest pipeline and decide whether the language should be stripped for the particular site through reading StripLanguage property on the site context .

You need to patch the custom processor created above as below.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
     <pipelines>
       <preprocessRequest>
         <processor type="YourNamespace.CustomStripLanguage, YourAssemblyName" patch:instead="processor[@type='Sitecore.Pipelines.PreprocessRequest.StripLanguage, Sitecore.Kernel']" />
       </preprocessRequest>
     </pipelines>
   </sitecore>
 </configuration>

Hope this helps!!! Let me know in case you face any issues.

Strip language is set inside the preprocessRequest pipeline which runs before the httpRequestBegin pipeline in which site context is set. Hence in order to obtain site context inside the custom processor created in the preprocessRequest pipeline using below code snippet.

using Sitecore.Pipelines.PreprocessRequest;
using Sitecore.Sites;
using Sitecore.Web;
using System.Linq;

public class CustomStripLanguage : StripLanguage
{
  public override void Process(PreprocessRequestArgs args)
  {
     var hostName = args.HttpContext.Request.Url.Host;
     SiteInfo site = SiteContextFactory.Sites
                .Where(s => s.RootPath != "" & s.HostName.Contains(hostName))
                .FirstOrDefault();
     if(site != null)
     {
        SiteContext contextSite =  SiteContextFactory.GetSiteContext(site.Name);
        // Based on the site context you can decide whether to strip language or not
        if(contextSite.Properties["StripLanguage"] == "false"){
           return;
        }
     }
     base.Process(args);
   }
}

Using above way, you should be successfully able to fetch site name inside preprocessRequest pipeline and decide whether the language should be stripped for the particular site through reading StripLanguage property on the site context .

Hope this helps!!! Let me know in case you face any issues.

Strip language is set inside the preprocessRequest pipeline which runs before the httpRequestBegin pipeline in which site context is set. Hence in order to obtain site context inside the custom processor created in the preprocessRequest pipeline using below code snippet.

using Sitecore.Pipelines.PreprocessRequest;
using Sitecore.Sites;
using Sitecore.Web;
using System.Linq;

public class CustomStripLanguage : StripLanguage
{
  public override void Process(PreprocessRequestArgs args)
  {
     var hostName = args.HttpContext.Request.Url.Host;
     SiteInfo site = SiteContextFactory.Sites
                .Where(s => s.RootPath != "" & s.HostName.Contains(hostName))
                .FirstOrDefault();
     if(site != null)
     {
        SiteContext contextSite =  SiteContextFactory.GetSiteContext(site.Name);
        // Based on the site context you can decide whether to strip language or not
        if(contextSite.Properties["StripLanguage"] == "false"){
           return;
        }
     }
     base.Process(args);
   }
}

Using above way, you should be successfully able to fetch site name inside preprocessRequest pipeline and decide whether the language should be stripped for the particular site through reading StripLanguage property on the site context .

You need to patch the custom processor created above as below.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
     <pipelines>
       <preprocessRequest>
         <processor type="YourNamespace.CustomStripLanguage, YourAssemblyName" patch:instead="processor[@type='Sitecore.Pipelines.PreprocessRequest.StripLanguage, Sitecore.Kernel']" />
       </preprocessRequest>
     </pipelines>
   </sitecore>
 </configuration>

Hope this helps!!! Let me know in case you face any issues.

added 173 characters in body
Source Link
ckhanna
  • 3.7k
  • 1
  • 1
  • 12

Strip language is set inside the preprocessRequest pipeline which runs before the httpRequestBegin pipeline in which site context is set. Hence in order to obtain site context inside the custom processor created in the preprocessRequest pipeline using below code snippet.

using Sitecore.Pipelines.PreprocessRequest;
using Sitecore.Sites;
using Sitecore.Web;
using System.Linq;

public class CustomStripLanguage : PreprocessRequestProcessorStripLanguage
{
  public override void Process(PreprocessRequestArgs args)
  {
     var hostName = args.HttpContext.Request.Url.Host;
     SiteInfo site = SiteContextFactory.Sites
                .Where(s => s.RootPath != "" & s.HostName.Contains(hostName))
                .FirstOrDefault();
     if(site != null)
     {
        SiteContext contextSite =  SiteContextFactory.GetSiteContext(site.Name);
        // Based on the site context you can decide whether to strip language or not
        if(contextSite.Properties["StripLanguage"] == "false"){
           return;
        }
     }
     base.Process(args);
   }
}

Using above way, you should be successfully able to fetch site name inside preprocessRequest pipeline and decide whether the language should be stripped for the particular site through reading StripLanguage property on the site context .

Hope this helps!!! Let me know in case you face any issues.

Strip language is set inside the preprocessRequest pipeline which runs before the httpRequestBegin pipeline in which site context is set. Hence in order to obtain site context inside the custom processor created in the preprocessRequest pipeline using below code snippet.

using Sitecore.Pipelines.PreprocessRequest;
using Sitecore.Sites;
using Sitecore.Web;
using System.Linq;

public class CustomStripLanguage : PreprocessRequestProcessor
{
  public override void Process(PreprocessRequestArgs args)
  {
     var hostName = args.HttpContext.Request.Url.Host;
     SiteInfo site = SiteContextFactory.Sites
                .Where(s => s.RootPath != "" & s.HostName.Contains(hostName))
                .FirstOrDefault();
     if(site != null)
     {
        SiteContext contextSite =  SiteContextFactory.GetSiteContext(site.Name);
        // Based on the site context you can decide whether to strip language or not
     }
   }
}

Using above way, you should be successfully able to fetch site name inside preprocessRequest pipeline and decide whether the language should be stripped for the particular site.

Hope this helps!!! Let me know in case you face any issues.

Strip language is set inside the preprocessRequest pipeline which runs before the httpRequestBegin pipeline in which site context is set. Hence in order to obtain site context inside the custom processor created in the preprocessRequest pipeline using below code snippet.

using Sitecore.Pipelines.PreprocessRequest;
using Sitecore.Sites;
using Sitecore.Web;
using System.Linq;

public class CustomStripLanguage : StripLanguage
{
  public override void Process(PreprocessRequestArgs args)
  {
     var hostName = args.HttpContext.Request.Url.Host;
     SiteInfo site = SiteContextFactory.Sites
                .Where(s => s.RootPath != "" & s.HostName.Contains(hostName))
                .FirstOrDefault();
     if(site != null)
     {
        SiteContext contextSite =  SiteContextFactory.GetSiteContext(site.Name);
        // Based on the site context you can decide whether to strip language or not
        if(contextSite.Properties["StripLanguage"] == "false"){
           return;
        }
     }
     base.Process(args);
   }
}

Using above way, you should be successfully able to fetch site name inside preprocessRequest pipeline and decide whether the language should be stripped for the particular site through reading StripLanguage property on the site context .

Hope this helps!!! Let me know in case you face any issues.

Source Link
ckhanna
  • 3.7k
  • 1
  • 1
  • 12

Strip language is set inside the preprocessRequest pipeline which runs before the httpRequestBegin pipeline in which site context is set. Hence in order to obtain site context inside the custom processor created in the preprocessRequest pipeline using below code snippet.

using Sitecore.Pipelines.PreprocessRequest;
using Sitecore.Sites;
using Sitecore.Web;
using System.Linq;

public class CustomStripLanguage : PreprocessRequestProcessor
{
  public override void Process(PreprocessRequestArgs args)
  {
     var hostName = args.HttpContext.Request.Url.Host;
     SiteInfo site = SiteContextFactory.Sites
                .Where(s => s.RootPath != "" & s.HostName.Contains(hostName))
                .FirstOrDefault();
     if(site != null)
     {
        SiteContext contextSite =  SiteContextFactory.GetSiteContext(site.Name);
        // Based on the site context you can decide whether to strip language or not
     }
   }
}

Using above way, you should be successfully able to fetch site name inside preprocessRequest pipeline and decide whether the language should be stripped for the particular site.

Hope this helps!!! Let me know in case you face any issues.