本文整理汇总了C#中Request.SetTriggerHtml方法的典型用法代码示例。如果您正苦于以下问题:C# Request.SetTriggerHtml方法的具体用法?C# Request.SetTriggerHtml怎么用?C# Request.SetTriggerHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request.SetTriggerHtml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public override bool Apply(Request request)
{
Uri u = request.Uri;
string url = u.Host + u.PathAndQuery;
if (u.Scheme == "connect")
url = "https://" + url;
else
url = u.Scheme + "://" + url;
foreach (KeyValuePair<string, List<RegexFilter>> kvp in hashList) {
if (kvp.Key != "" && url.Contains (kvp.Key) == false)
continue;
foreach (RegexFilter regex in kvp.Value) {
if (regex.IsMatch (url) == false)
continue;
request.Flags.Set (regex.Flags);
request.SetTriggerHtml (Html.Escape ("Adblock filter: " + regex.Pattern + "\n" + url));
return true;
}
}
return false;
}
示例2: Apply
public override bool Apply(Request httpRequest)
{
string referer;
string request;
if (httpRequest.Referer == null)
referer = "";
else
referer = new Uri (httpRequest.Referer).Host;
request = httpRequest.Uri.Host;
if (request == referer)
return false;
using (listLock.Read) {
foreach (RefererPair pair in watchlist) {
if (pair.MatchFrom (referer) == false)
continue;
if (pair.MatchTo (httpRequest.Dns.NameList) == false)
continue;
httpRequest.Flags.Set (pair.Flags);
if (pair.Flags ["block"]) {
httpRequest.SetTriggerHtml (Html.Format (@"
<h1 style=""text-align:center""><a href=""{0}"" style=""font-size: 3em;"">{1}</a></h1>
<p>Blocked by: {2} <a href=""{3}?delete={4}&return={5}"">delete</a></p>", httpRequest.Uri, httpRequest.Uri.Host, pair, Filters.WebUI.FilterUrl (this), pair.GetHashCode (), Uri.EscapeUriString (httpRequest.Uri.ToString ())));
return true;
}
httpRequest.SetTriggerHtml (Html.Escape (pair.ToString ()));
return true;
}
}
//Already blocked, don't add to blocked list
if (httpRequest.Flags ["block"])
return true;
using (listLock.UpgradeableRead) {
foreach (string h in httpRequest.Dns.NameList) {
RefererPair rp = new RefererPair (referer, h);
if (blocked.Contains (rp) == false) {
using (listLock.Write) {
blocked.Insert (0, rp);
}
}
}
}
//Allow empty referers
if (referer == "")
return false;
//Default action: none(pass)
return false;
//Default action: Remove
//httpRequest.Flags.Set ("remove");
//Default action: Block
/*
httpRequest.Flags.Set ("block");
httpRequest.SetTriggerHtml (Html.Format (@"
<h1 style=""text-align:center""><a href=""{0}"" style=""font-size: 3em;"">{1}</a></h1>
<p style=""text-align:center""><a href=""{0}"">{2}</a></p>", httpRequest.Uri, httpRequest.Uri.Host, httpRequest.Uri.PathAndQuery));
httpRequest.SetTriggerHtml (Form (referer, httpRequest.Uri.Host, httpRequest.Uri.ToString ()));
return true;
*/
}