Skip to content

Instantly share code, notes, and snippets.

@MichalGrzegorzak
Forked from sclarson/gist:2344489
Created February 12, 2013 08:46
Show Gist options
  • Save MichalGrzegorzak/4761023 to your computer and use it in GitHub Desktop.
Save MichalGrzegorzak/4761023 to your computer and use it in GitHub Desktop.
this.PageName = node.SelectSingleNode("T") != null ? EPiServer.Core.Html.TextIndexer.StripHtml(node.SelectSingleNode("T").InnerXml.Trim().HtmlDecode(),200) : string.Empty;
if (this.PageName.IsNullOrWhiteSpace())
{
this.PageName = "( No Title )";
var UseWebRequestToResolveSupportTitle =
WebConfigurationManager.AppSettings["UseWebRequestToResolveSupportTitle"] != null && Convert.ToBoolean(WebConfigurationManager.AppSettings["UseWebRequestToResolveSupportTitle"]);
if (UseWebRequestToResolveSupportTitle)
{
var cachedTitle =
(string)EPiServer.CacheManager.Get(SupportCacheKey);
if (string.IsNullOrEmpty(cachedTitle))
{
// Make the WebClient we'll be using able to handle support's bad cert
var sslFailureCallback = new RemoteCertificateValidationCallback(delegate { return true; });
ServicePointManager.ServerCertificateValidationCallback += sslFailureCallback;
var client = new WebClient();
var html = client.DownloadString(this.PageURL);
// Retrieve just the title
var title = Regex.Match(html, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value;
EPiServer.CacheManager.Add(SupportCacheKey,title);
cachedTitle = title;
}
this.PageName = cachedTitle;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment