HttpBrowserCapabilities自定义浏览器文件解析 [英] HttpBrowserCapabilities Custom Browser file parsing

查看:331
本文介绍了HttpBrowserCapabilities自定义浏览器文件解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个自定义的.browser文件,并且我想评估如果给它一个特定的用户代理,将会发生什么,是否有任何方法可以通过.NET API做到这一点?

If I have a custom .browser file, and I want to evaluate what will happen if it is given a particular User Agent, is there any way to do that through the .NET API?

我试图使用HttpBrowserCapabilites,但是我不确定如何将自定义.browser文件加载到该类中.

I was attempting to use HttpBrowserCapabilites, but I'm not sure how to load a custom .browser file into that class.

推荐答案

通常,您不必显式加载HttpBrowserCapabilities类.只要您将.browser文件放在正确的位置(在App_Browsers中),ASP.NET就会为您加载它.

Normally, you should not have to explicitly load the HttpBrowserCapabilities class; ASP.NET will load it for you, as long as you have your .browser file in the right place (in App_Browsers).

但是,进行测试将是另一个问题.您无法从HttpApplication(global.asax)或自定义HttpModule内修改"User-Agent" HTTP标头.

However, testing it will be another problem. You can't modify the "User-Agent" HTTP Header from within either the HttpApplication (global.asax) or a custom HttpModule.

这仅留下笨拙的技术,例如使用反射来强制值,或使用外部工具(例如Fiddler).或者,如果您精通C/C ++,则可以举一个简单的ISAPI筛选器示例并对其进行修改,然后将其安装在IIS中.

This leaves only awkward techniques, such as using Reflection to force the value, or using an external tool (such as Fiddler). Alternately, if you're good with C/C++, you could take a simple example for an ISAPI filter and modify it, then install it in IIS.

这篇关于HttpBrowserCapabilities自定义浏览器文件解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆