Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom User Agent for a WebView

can I set a custom User Agent for a WebView?

I need to show mobile style of websites.

like image 671
MBZ Avatar asked Dec 08 '12 04:12

MBZ


2 Answers

It's easy to do:

string ua = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X)" + "AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25";
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, new Uri(url));
httpRequestMessage.Headers.Add("User-Agent",ua);
webView1.NavigateWithHttpRequestMessage(hrm);
like image 173
John TiXor Avatar answered Sep 29 '22 12:09

John TiXor


Per this MSDN Forum posting you cannot. Could you host a lightweight proxy service (say Azure Web Site) to proxy the request for you?

like image 24
Jim O'Neil Avatar answered Sep 29 '22 14:09

Jim O'Neil