This class will allow you to attain the real user agent string for a device, as used by the embedded WebBrowser control.
A meaningful user agent string can then be manually set for HTTP requests instead of the default NativeHost
user agent that is sent by the WebClient.
An example user agent would look something like:
Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; NOKIA; Lumia 920)
- Create an instance of the helper
- Create a handler for GotUserAgent
- Grab the user agent string from UserAgentEventArgs
After attaining the user agent with this class you can attach it to WebClient request as follows:
WebHeaderCollection headers = new WebHeaderCollection();
headers[HttpRequestHeader.UserAgent] = userAgentString;
WebClient webClient = new WebClient();
webClient.Headers = headers;
When targeting your application at Windows Phone 7.1, the user agent will always state Windows Phone OS 7.5 even on 8.0 and above.