是否可以禁用 ASP.NET 中的 browserCaps 功能?
是否可以禁用 ASP.NET 中的 browserCaps 功能?
我希望我的网站能够可靠且完全按照我为所有浏览器定义的方式提供服务,无论其功能如何。
如果他们的浏览器不支持该网站,那就是他们的问题。我的网站不应该试图自我降级以适应已失效的客户。
当蜘蛛似乎运气不好时,这非常令人沮丧,我猜爬行该网站,获取该网站的较小版本,导致输出缓存为剥离的文件提供服务。
Is it possible to disable the browserCaps functionality in ASP.NET?
I wish my site to be served reliably and exactly as I have it defined to all browsers regardless of their capabilities.
If their browser can't support the site, that's their problem. My site should not be some how attempting to degrade itself to accommodate the defunct client.
This is very frustrating when it seems to have the bad luck of spiders I guess crawling the site, getting the lesser version of the site causing output caching to serve the stripped file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 ClientTarget="uplevel" 放在页面指令或 Page.Init 中
,或者
另一个选项是添加 .browser 文件复制到您网站的 App_Browsers 文件夹(默认的 Asp.NET 文件夹)中。它应该使用正则表达式针对所有浏览器,并通过添加功能以某种方式禁用正常的浏览器检测。我只是用它来在 Safari 中以正确的方式呈现菜单控件,但我并不完全知道如何同时对所有输出执行此操作。
You can put ClientTarget="uplevel" in the page directive or in the Page.Init
or
Another option is to add a .browser file to your site, in the folder App_Browsers (a default Asp.NET folder). It should target all browser with a regex expression and somehow disable the normal browser detection by adding capabilities. I'm only using this to render the Menu control the right way in Safari but I don't exactly know how to do this for all output at once.
我目前正在尝试的一个疯狂的解决方法是注入我们自己的
HttpCapabilityDefaultProvider
,它返回一个静态HttpBrowserCapability
。诀窍是始终返回相同的功能对象,因此通过在使用 IE9 时调用base.GetBrowserCapability
,我们使用 Newtonsoft 创建序列化,并通过将此字符串保存在源中,我们可以构建一个类似 IE9 的功能对象,无论哪个浏览器发起请求。然后在
Application_Start
中分配提供程序:但这尚未经过真正测试,不确定此更改的具体影响是什么。
An insane workaround I'm currently trying out is to inject our own
HttpCapabilitiesDefaultProvider
which returns a staticHttpBrowserCapabilities
. The trick then is to always return the same capabilities object, so by callingbase.GetBrowserCapabilities
while using IE9, we've used Newtonsoft to create a serialization, and by saving this string in the source, we can build an IE9 like capabilities object regardless of what browser initiated the request.and then assigning the provider in
Application_Start
:This hasn't really been tested however, unsure of what exactly is the impact of this change.