Ravi
Ravi

Reputation: 173

How to change the windows phone user agent

I'm making a web browser control and my code to change the user agent doesn't seem to work.

    webBrowser1.Navigate(new Uri(textBox1.Text, null, null, "User-Agent: Mozilla 5.0 (Linux; U; Android 2.3.7; zh-cn; MB525 Build MIUI) UC AppleWebKit 534.31 (KHTML, like Gecko) Mobile Safari 534.31", UriKind.Absolute));

I like this user agent because it seems to load pages in a mobile format easier to use.

Upvotes: 1

Views: 2308

Answers (1)

Dai
Dai

Reputation: 155250

Your syntax is incorrect. This is what you've got (formatted):

webBrowser1.Navigate(
    new Uri(
        textBox1.Text,
        null,
        null,
        "User-Agent: Mozilla 5.0 (Linux; U; Android 2.3.7; zh-cn; MB525 Build MIUI) UC AppleWebKit 534.31 (KHTML, like Gecko) Mobile Safari 534.31",
        UriKind.Absolute
    )
);

This is what it should be (using this as the reference: http://msdn.microsoft.com/en-US/library/windowsphone/develop/ff626636(v=vs.105).aspx )

webBrowser1.Navigate(
    new Uri(
        textBox1.Text
    ),
    null,
    "User-Agent: Mozilla 5.0 (Linux; U; Android 2.3.7; zh-cn; MB525 Build MIUI) UC AppleWebKit 534.31 (KHTML, like Gecko) Mobile Safari 534.31"
);

Upvotes: 1

Related Questions