Windows phone 7 web browser control user agent

心已入冬 提交于 2019-12-22 18:40:16

问题


The present user agent for the browser control that i see in the emulator is Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; Microsoft; XDeviceEmulator) and i want to change that to Mozilla/5.0 Windows NT 6.1 AppleWebKit/535.1 KHTML, like Gecko Chrome/14.0.835.187 Safari/535.1 or something similar.

How to code that in C# to change the user agent string for the web browser control.


回答1:


Found a way webBrowser.Navigate("http://localhost/run.php", null, "User-Agent: Here Put The User Agent");




回答2:


In Windows Phone 7.5, there is a Navigate method overload that allows setting the headers. There are 3 arguments ( URI, post_info, header_info) , not 4 as shown.

The overload worked for me.

Good luck. -e




回答3:


In the end I found an unbelievably simple answer, and that worked.

All you need do is to edit the Web Browser Control XAML. Add the property IsScriptEnabled="True"

Hope this solutions helps.




回答4:


Would be something like this, in vb:

WebBrowser.Navigate(New Uri("URL"), byteArr, HttpRequestHeader.UserAgent & ":" & "Mozilla/5.0 (Linux; U; Android 2.3.4; fr-fr; HTC Desire Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1")

However, I cannot modify the headers already appended to the request, you can only add them, which I find pretty annoying.

Anyone have succeeded in doing this??



来源:https://stackoverflow.com/questions/7631740/windows-phone-7-web-browser-control-user-agent

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