HttpBrowserCapabilities Custom Browser file parsing

做~自己de王妃 提交于 2019-12-11 06:07:37

问题


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?

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


回答1:


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).

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.

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.




回答2:


Install the User Agent Switcher Firefox extension. It will let you adjust the user agent the browser sends to the web server.

http://chrispederick.com/work/user-agent-switcher/



来源:https://stackoverflow.com/questions/831352/httpbrowsercapabilities-custom-browser-file-parsing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!