private static NavigationSiteMapNode GetNode(ReadOnlyUrl url) { // Try with the query first and then just the path. var node = _siteMapProvider.FindSiteMapNode(url.PathAndQuery) as NavigationSiteMapNode; return(node ?? _siteMapProvider.FindSiteMapNode(url.Path) as NavigationSiteMapNode); }
public static SiteMapNode GetCurrentNode(SiteMapProvider selectedSiteMapProvider) { // get the node matching the current URL location var currentNode = selectedSiteMapProvider.CurrentNode; // if there is no node matching the current URL path, // remove parts until we get a hit if (currentNode == null) { var url = HttpContext.Current.Request.Url.LocalPath; while (url.Length > 0) { // see if we can find a matching node currentNode = selectedSiteMapProvider.FindSiteMapNode(url); // if we get a hit, stop if (currentNode != null) { break; } // if not, remove the last path item var lastSlashlocation = url.LastIndexOf("/"); if (lastSlashlocation < 0) { break; // protects us from malformed URLs } url = url.Remove(lastSlashlocation); } } return(currentNode); }
private SiteMapNode FindSiteMapNode(string url) { if (SiteMapProvider == null) { return(null); } SiteMapNode node; if (_findSiteMapNodeCache.TryGetValue(url, out node)) { return(node); } node = SiteMapProvider.FindSiteMapNode(url); _findSiteMapNodeCache[url] = node; return(node); }
private void Context_EndRequest(object sender, EventArgs e) { HttpApplication application = (HttpApplication)sender; bool isBackendRequest = application.Context.Items.Contains(SystemManager.IsBackendRequestKey) && (bool)application.Context.Items[SystemManager.IsBackendRequestKey]; if (!Bootstrapper.IsReady || !IsSfModuleActive() || application.Context.Request.Url.AbsolutePath == RequestSpyHttpModule.requestSpyUrl || isBackendRequest) { return; } if (Config.Get <RequestSpyConfig>().PagesOnly) { SiteMapProvider siteMapProvider = SiteMapBase.GetSiteMapProvider("FrontendSiteMap"); var frontendPage = siteMapProvider.FindSiteMapNode(application.Context.Request.Url.AbsolutePath); bool isFrontendPage = frontendPage != null; if (!isFrontendPage && application.Context.Response.StatusCode == 200) // status code condition added in order to catch non-200 requests, e.g. 404 { return; } } if (RequestSpyHttpModule.requestBuffer.Count == 15) { RequestSpyHttpModule.requestBuffer.Take(); } RequestSpyHttpModule.requestBuffer.Add(new RequestDto() { Id = Guid.NewGuid().ToString(), Url = application.Context.Request.Url.AbsoluteUri, Protocol = application.Context.Request.Url.Scheme, Response = new ResponseDto(application.Context.Response.StatusCode) }); }