Created
June 7, 2023 05:16
-
-
Save thaitranet/44292aac5ed8d84be3b090c2a175d963 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.DependencyInjection; | |
using Sitecore.DependencyInjection; | |
using Sitecore.Pipelines; | |
using Sitecore.XA.Foundation.Multisite; | |
using Sitecore.XA.Foundation.SitecoreExtensions.Session; | |
using System.Linq; | |
using System.Web.Http; | |
using System.Web.Routing; | |
namespace Platform.Pipelines | |
{ | |
public class RegisterRoutes | |
{ | |
public void Process(PipelineArgs args) | |
{ | |
foreach (string virtualdir in ServiceLocator.ServiceProvider.GetService<ISiteInfoResolver>() | |
.Sites.Select(s => s.VirtualFolder.Trim('/')).Distinct()) | |
{ | |
string sitepath = virtualdir.Length > 0 ? virtualdir + "/" : virtualdir; | |
RouteTable.Routes.MapHttpRoute( | |
name: sitepath + "sxaresults", | |
routeTemplate: sitepath + "sxa/search/results", | |
defaults: new { controller = "XASearchOverride", action = "GetResultsOverride" } | |
).RouteHandler = new SessionHttpControllerRouteHandler(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment