//private int GetIndexOfLastMatchedSymbol(string x, string y) //{ // x = x.ToUpper(); // y = y.ToUpper(); // var index = 0; // for (index = 0; index < Math.Min(x.Length, y.Length); index++) // { // if (x[index].Equals(y[index]) == false) // { // break; // } // } // return index; //} public override SiteMapNode FindSiteMapNode(HttpContext context) { SiteMapNode node = null; var uri = context.Request.Url; var qs = new ComparableQueryString(context.Request.QueryString); try { var filter = string.Format("{0} LIKE '%{1}%'" , GT.DA.SiteMap.SiteMap.URL_COL, uri.GetComponents( UriComponents.Path, UriFormat.UriEscaped)); var nodes = GT.DA.SiteMap.SiteMap.Instance.Data.Tables[0].Select(filter , string.Format("{0} ASC", GT.DA.SiteMap.SiteMap.ID_COL)); var index = -1; var key = -1; for(int i = 0; i < nodes.Length; i++) { var nodeUrl = nodes[i][GT.DA.SiteMap.SiteMap.URL_COL].ToString().TrimStart('~','/'); var questionIndex = nodeUrl.IndexOf('?'); if(questionIndex > 0 && nodeUrl.Contains("?&") == false) { nodeUrl = nodeUrl.Insert(questionIndex + 1, "&"); } var nodeQueryString = HttpUtility.ParseQueryString(nodeUrl); var temp = qs.GetEqualityIndex(nodeQueryString); if(temp > index) { index = temp; key = (int)nodes[i][GT.DA.SiteMap.SiteMap.ID_COL]; } } if(key > -1) { node = FindSiteMapNodeFromKey(key.ToString()); } } catch (Exception e) { AssistLogger.Log<WebExceptionHolder>(new Exception("Cannot resolve sitemap node.", e)); } if(node == null) { node = base.FindSiteMapNode(context); } return node; }