简体   繁体   中英

Best way to detect major search engines in C# MVC

I found the following question but if possible I don't want to have to make changes that will affect all sites on the server. HttpBrowserCapabilities.Crawler property .NET

I also found instructions on using the browserCaps Element http://msdn.microsoft.com/en-us/library/sk9az15a.aspx but it seems to be deprecated.

What is the easiest way to detect the major search engines in Asp.net 4.0?

(I am only really interested in being able to detect major search engines)

Just the same way as you would in a normal ASP.Net site.

        if( Request.Browser.Crawler )
        {

        }

You can add an httpmodule to do detection on all requests.

Checkout Browser Caps here

Or

Get the HttpRequest.UserAgent and check it against a list of know user agents .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM