This is for Windows Phone. I'm using windowsphone8.1 update 1. you know that the web interface works like that of android and iOS. How do I get the same interface in my wp8.1 web-apps? I downloaded and installed WP8.1 Update 1 SDK. I don't see Wp8.1 update 1 version to select when I open a new project. Can I get updated web interface in WP8.1 or Cyan updated users?
Asked
Active
Viewed 1,591 times
2 Answers
2
Windows Phone 8.1 Update 1 does not introduce any new public APIs for developers.
If you're working with the WebView
(aka the WebBrowser
) control in a Windows Phone 8.1 XAML project and you want to specify a different user-agent for the entire session, use...
[DllImport("urlmon.dll", CharSet = CharSet.Ansi)]
private static extern int UrlMkSetSessionOption(int dwOption, string pBuffer, int dwBufferLength, int dwReserved);
const int URLMON_OPTION_USERAGENT = 0x10000001;
public void ChangeUserAgent(string Agent)
{
UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, Agent, Agent.Length, 0);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
ChangeUserAgent("My Custom User-Agent");
wb.Navigate(new Uri("http://basquang.wordpress.com/2014/04/26/wp8-1-changing-windows-phone-8-1-webview-default-user-agent-in-all-outbound-http-requests/", UriKind.Absolute));
}
Source: basquang on clouds blog

Neil Turner
- 2,712
- 2
- 18
- 37
-
5This approach will cause you to fail certification with: "This API is not supported for this application type - Api=UrlMkSetSessionOption. Module=urlmon.dll" – Craig Presti - MSFT Sep 30 '14 at 02:06
-
1This approach will work in debug version, but will get the certification failure exactly as @craigomatic mentioned, so the app won't be publishable in the store. Can anyone show any other better solution? – Touhid Aug 17 '15 at 11:11
0
An alternative in this post https://social.msdn.microsoft.com/Forums/en-US/e7954cf9-88ba-4318-aebf-f528ade5c13d/still-no-way-to-set-ua-string-in-81-webview?forum=w81prevwCsharp answered by _Pete
HttpRequestMessage httpRequestMessage =
new HttpRequestMessage(HttpMethod.Post, new Uri("website"));
httpRequestMessage.Headers.Append("User-Agent",
"Custom User-Agent");
webView.NavigateWithHttpRequestMessage(
httpRequestMessage);
Obviously it works for one Uri

La masse
- 1,190
- 1
- 10
- 24
-
This works for single navigation, but not for any requests made in the WebView or when navigating to other pages in the WebView. – Martin Suchan Oct 07 '16 at 09:55