Search code examples
asp.netsitecoresitecore6

Which method to retrieve path portion of URL in Sitecore?


I'm writing an extension to the HTTPRequest pipeline to redirect incoming requests where Sitecore can find the right item but where the requested URL isn't formed exactly as Sitecore would form it. This is to prevent SEO duplicate content issues.

The portion of the URL I want to examine is the part that will conform to the LinkManager.GetItemUrl(context.item) result. In our case we have language embedded in the path, e.g.:

www.mysite.com/en-gb/stuff/things

So GetItemUrl returns /en-gb/stuff/things

I can't find the right method, either on the Sitecore.Pipelines.HttpRequest.HttpRequestArgs object, nor on the System.Web.HttpContext.Current.Request.Url object.

I can get the whole URL or the path minus language embedding. Which object.method will give me /en-gb/stuff/things?


Solution

  • I'm not sure if I understood you correctly but it seems like what you're looking for is System.Web.HttpContext.Current.Request.RawUrl . If not, please explain what you want to achieve with more details.