我试着从Oceans BrowserCap文件中寻找灵感,但这对我来说有点过了。
基本上,我需要在.browser文件中包含与此相同的内容
<browserCaps>
<filter>
<!-- Google Crawler -->
<case match="Googlebot">
browser=Googlebot
crawler=true
</case>
</filter>
</browserCaps>但我就是想不通。任何帮助都是最好的
发布于 2010-08-23 12:42:36
明白了..。这是给下一个需要它的人的。
<browsers>
<browser id="Googlebot" parentID="Mozilla">
<identification>
<userAgent match="Googlebot" />
</identification>
<capabilities>
<capability name="crawler" value="true" />
</capabilities>
</browser>
</browsers>这是我的MVC ActionFilterAttribute,我用它来检测Goog..
Imports System.Web.Mvc
Imports System.Net
Imports System.Web
Namespace Filters
<AttributeUsage(AttributeTargets.Method, AllowMultiple:=False)> _
Public Class SearchBotFilter : Inherits ActionFilterAttribute
Public Overrides Sub OnActionExecuting(ByVal c As ActionExecutingContext)
If Not HttpContext.Current.Request.Browser.Crawler Then
HttpContext.Current.Response.StatusCode = CInt(HttpStatusCode.NotFound)
c.Result = New ViewResult() With {.ViewName = "NotFound"}
End If
End Sub
End Class
End Namespace
End Classhttps://stackoverflow.com/questions/3544767
复制相似问题