public override RouteData GetRouteData(HttpContextBase httpContext) { var route = GetRoute(GetApplicationPathForSiteMarker(httpContext)); if (route == null) { return(null); } HttpContextBase mockHttpContext = httpContext; bool pathHasLanguageCode; IWebsiteLanguage websiteLangauge; // multilanguage is enabled if we find a language string pathWithoutLanguageCode = ContextLanguageInfo.StripLanguageCodeFromAbsolutePath(httpContext, out pathHasLanguageCode, out websiteLangauge); if (websiteLangauge != null && pathHasLanguageCode) { var urlWithoutLanguageCode = httpContext.Request.Url.GetLeftPart(UriPartial.Authority) + pathWithoutLanguageCode; HttpRequest request = new HttpRequest(httpContext.Request.FilePath, urlWithoutLanguageCode, httpContext.Request.Url.Query); mockHttpContext = new MockRequestHttpContext(new HttpRequestWrapper(request)); } var routeData = route.GetRouteData(mockHttpContext); return(routeData == null ? null : WrapRouteData(routeData)); }
private string GetPortalContextPath(string path, ApplicationPath applicationPath) { if (applicationPath == null || applicationPath.AbsolutePath == null) { return(null); } // Create a route for this application path, filtering out any IRouteConstraint constraints. We // don't support these here, since we're only passing a mock HTTP context that doesn't support // the full range of properties a real one would. Only regex-based constraints can be supported // here. var route = GetRoute(applicationPath, constraint => !(constraint.Value is IRouteConstraint)); if (route == null) { return(null); } var routeData = route.GetRouteData(MockRequestHttpContext.FromPath(path)); return(routeData == null ? null : applicationPath.AbsolutePath); }