Friday 2 October 2015

Detect request is a Crawler / bot or End user request

Leave a Comment
Some project might store some information where is the request come.

This code snippet is show how you can determine the request is a crawler or not.

Code Behind 

   /// <summary>  
     /// Returns whether browsing device is search engine crawler (spider, bot).  
     /// </summary>      
     public bool IsCrawler()  
     {  
       if (HttpContext.Current != null)  
       {  
         HttpRequest currentRequest = HttpContext.Current.Request;  
         return (currentRequest.Browser != null) && currentRequest.Browser.Crawler;  
       }  
       return false;  
     }  

You can put this method under static class and call it from Global.asax file.

By
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

0 comments:

Post a Comment

Subscribe to our newsletter to get the latest updates to your inbox.

Your email address is safe with us!




Founder of developersnote.com, love programming and help others people. Work as Software Developer. Graduated from UiTM and continue study in Software Engineering at UTMSpace. Follow him on Twitter , or Facebook or .



Powered by Blogger.