在 WP8.1 WebView 中更改用户代理 [英] Change user agent in WP8.1 WebView
问题描述
这适用于 Windows Phone.我正在使用 windowsphone8.1 更新 1.您知道 Web 界面的工作方式类似于 android 和 iOS.如何在我的 wp8.1 网络应用程序中获得相同的界面?我下载并安装了 WP8.1 Update 1 SDK.当我打开一个新项目时,我没有看到 Wp8.1 update 1 版本可供选择.我可以在 WP8.1 或青色更新用户中获得更新的网络界面吗?
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?
推荐答案
Windows Phone 8.1 Update 1 没有为开发人员引入任何新的公共 API.
Windows Phone 8.1 Update 1 does not introduce any new public APIs for developers.
如果您使用 WebView
(又名 WebBrowser
)控件在 Windows Phone 8.1 XAML 项目中,并且您想要为整个项目指定不同的用户代理会话,使用...
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));
}
来源:basquang 云博客
这篇关于在 WP8.1 WebView 中更改用户代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!