Windows10中MS-WebView中的自定义用户代理 [英] Custom User Agent in MS-WebView in windows10

查看:104
本文介绍了Windows10中MS-WebView中的自定义用户代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我们正在构建基于cordova插件的混合Windows移动应用程序。我们正在尝试在Windows 10中的MS-Webview中设置自定义用户代理。我们在下面尝试过它并没有设置自定义用户代理。 Microsoft是否支持MS-WebView中的自定义用户代理

We are building a hybrid windows mobile app based on cordova plugins. We are trying to set custom user agent in MS-Webview in windows 10. We tried below and it does not set the custom user agent. Does Microsoft support custom user agent in MS-WebView

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";
                Uri targetUri = new Uri(url);
                HttpRequestMessage hrm=new HttpRequestMessage(HttpMethod.Get,targetUri);
                hrm.Headers.Add("User-Agent",ua);
                webView1.NavigateWithHttpRequestMessage(hrm);

推荐答案

嗨Sdherungula,

Hi Sdherungula,

>> Microsoft是否支持MS-WebView中的自定义用户代理?

>>Does Microsoft support custom user agent in MS-WebView?

是的,确实如此。我们可以使用HttpRequestMessage.Headers.Add方法将自定义用户代理设置为WebView。我测试它是否有效。

Yes, it does. We can use the HttpRequestMessage.Headers.Add method to set custom user agent to the WebView. I test it that it works.

另外,如何获取有关它的信息未设置自定义用户代理?

Also how do you get info about it does not set the custom user agent?

最好的问候,

Jayden Gu

Jayden Gu


这篇关于Windows10中MS-WebView中的自定义用户代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆