C's method of determining whether the source of access is a search engine link

  • 2021-01-06 00:42:47
  • OfStack

This article illustrates C#'s method of determining whether a source of access is a search engine link. Share to everybody for everybody reference. The specific analysis is as follows:

This code by obtaining UrlReferrer to determine whether the visitor from the common search engine, not completely accurate, can do reference


///  Determine if it comes from a search engine link 
///  Whether from a search engine link 
public static bool IsSearchEnginesGet()
{
if (HttpContext.Current.Request.UrlReferrer == null)
{
return false;
}
string[] SearchEngine = { "google", "yahoo", "msn", "baidu", "sogou", "sohu", "sina", "163", "lycos", "tom", "yisou", "iask", "soso", "gougou", "zhongsou","bing" };
string tmpReferrer = HttpContext.Current.Request.UrlReferrer.ToString().ToLower();
for (int i = 0; i < SearchEngine.Length; i++)
{
if (tmpReferrer.IndexOf(SearchEngine[i]) >= 0)
{
return true;
}
}
return false;
}

I hope this article is helpful to your C# program design.


Related articles: