-
-
Save MichalGrzegorzak/4761023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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