Cordova + Bing地图+内容安全政策(Cordova + Bing Maps + Content Security Policy)

我正在VisualStudio 2015中开发Cordova应用程序。我正在尝试在其中一个页面中添加BingMaps模块以在地图上显示特殊位置。 因此,我在index.html中引用它:

<script type="text/javascript" src="ms-appx:///Bing.Maps.JavaScript//js/veapicore.js"></script>

在我的控制器中,我使用以下命令:

Microsoft.Maps.loadModule(
  'Microsoft.Maps.Map',
  {
    callback: function () {/*my code here*/}
  }
);

当我启动应用程序时,我有这个错误:

拒绝加载脚本'ms-appx:///Bing.Maps.JavaScript//js/veapicore.js',因为它违反了以下内容安全策略指令:“default-src'self'data:gap: https:/ /ssl.gstatic.com'unsafe-eval '“。 请注意,'script-src'未明确设置,因此'default-src'用作后备。

我的内容安全策略是Cordova插入的默认行:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">

我尝试更改(并删除)此行而没有任何结果。

如果有帮助,我正在调试Ripple中的应用程序


I'm developing a Cordova application in VisualStudio 2015. I'm trying, in one of the pages, to add a BingMaps module to display a special location on a map. Therefore, I reference this in my index.html :

<script type="text/javascript" src="ms-appx:///Bing.Maps.JavaScript//js/veapicore.js"></script>

And in my controler, I use the following command :

Microsoft.Maps.loadModule(
  'Microsoft.Maps.Map',
  {
    callback: function () {/*my code here*/}
  }
);

When I launch the application, I have this error :

Refused to load the script 'ms-appx:///Bing.Maps.JavaScript//js/veapicore.js' because it violates the following Content Security Policy directive: "default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

My Content-Security-Policy is the default line, inserted by Cordova :

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">

I tried to change (and to remove) this line without any result.

If it helps, I'm debugging the application in Ripple


原文:https://stackoverflow.com/questions/35392565
2022-03-14 22:03

满意答案

好吧,经过多次搜索并将我的头撞在桌子上,我已经把这个东西搞定了。 我以为我昨天有它工作,但它只适用于Windows 7而不适用于XP ..

所以,在这里:

IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, Port);

UdpClient client = new UdpClient();
client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
client.Client.Bind(localEndPoint);
client.JoinMulticastGroup(IPAddress);
client.MulticastLoopback = true;

Client.BeginReceive(MessageReceived, null);

我当然希望记录得更好,但我想这就是为什么我们得到了大笔钱。

感谢StackOverflow提供这样一个AWESOME知识库,从中提取这些东西!!


Ok, after much searching and banging my head on my desk, I've got this thing working. I thought I had it working yesterday, but it only worked on Windows 7 and not on XP..

So, here it goes:

IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, Port);

UdpClient client = new UdpClient();
client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
client.Client.Bind(localEndPoint);
client.JoinMulticastGroup(IPAddress);
client.MulticastLoopback = true;

Client.BeginReceive(MessageReceived, null);

I sure wish this was documented a bit better, but I guess that's why we get the big bucks $$$.

Thanks StackOverflow for providing such an AWESOME knowledgebase from which to extract this stuff !!

相关问答

更多

代码中的多播地址未在DDS代码中设置(Multicast address in code not getting set in DDS code)

尝试使用set_default_participant_qos(DomainParticipantQos qos)方法将修改后的qos设置为新的默认qos。 参见RTI Connext Java API try the set_default_participant_qos(DomainParticipantQos qos) method to set the modified qos as new default qos. see RTI Connext Java API

连接后UdpClient无法接收(UdpClient can't receive after connect)

http://msdn.microsoft.com/en-us/library/c4w4cta7(v=vs.110).aspx : 如果调用Connect方法,则将丢弃从非指定默认地址到达的任何数据报。 您希望收到的数据报来自不同的地址。 也许发件人使用LAN或WAN IP地址而不是环回( 127.0.0.1 )地址。 如果您不需要 Connect呼叫,只需将其删除即可。 http://msdn.microsoft.com/en-us/library/c4w4cta7(v=vs.110).aspx...

当UdpClient正在侦听不再可用的地址时,我该如何处理?(How can I handle when a UdpClient is listening on an address which is no longer available?)

UDP完全是无状态的。 经验法则是:你不能依赖任何东西。 不是发送,不是接收,不是在出现问题时出错。 UDP静静地坐着等待下一个数据包。 通过将其绑定到端点,您只需告诉它丢弃未明确发送到此端点的任何内容。 因此,如果用户禁用了他的网卡,它仍然会等待发送到绑定端点的数据包,即使数据包无法到达也是如此。 只要再次激活卡,并且有人发送到该端点,UDP客户端就会收到它,就好像什么都没发生一样。 长话短说:您的UdpClient不是软件的选择,无法确定网卡是否被禁用。 如果你真的想要处理这种情况,你必须找到...

UdpClient接收到127.0.0.1的数据包,但无法获取接口IP地址(UdpClient receives packets to 127.0.0.1 but fails to get them for interface IP address)

好吧,5353是Apple Bonjour服务(Zeroconf)。 因此,当Bonjour运行时,它会在到达客户端之前捕获这些数据报。 在服务中禁用它将数据包泵送到我的应用程序。 Well, 5353 is Apple Bonjour service (Zeroconf). So while Bonjour is running it captures these datagrams before they reach the client. Disabling it in Services p...

如何在asio中找到多播发送方地址?(How to find multicast sender address in asio?)

由于任何机器都可以向多播组广播,您需要做的是使用upd :: socket对象上的receive_from或async_receive_from方法开始侦听消息。 这些方法将使用远程对等详细信息填充端点对象,然后您可以将其解析为地址。 As any machine could be broadcasting to the multicast group, what you need to do is to start listening to messages, using the receive...

C#等待udpClient.ReceiveAsync()失败并终止程序(C# await udpClient.ReceiveAsync() fails and terminates program)

await udpClient.ReceiveAsync()的调用不会终止程序,也不会失败。 鉴于这种情况正在发生,我假设你有这样的事情: public static void Main(string[] args) { ... Run(); } 在async void方法中,一旦到达await调用,控制就会返回给父项,所以程序的流程如下所示: public static void Main(string[] args) { ... var armIpAddres...

C#UdpCLient.Receive在不同的机器上没有收到任何数据(C# UdpCLient.Receive doesn't receive any data on different machine)

根据您的解释(它不能仅在另一台机器上运行)和您的代码,它似乎是一个端口转发问题。 您可以在此处阅读更多相关信息: https : //en.wikipedia.org/wiki/Port_forwarding 端口转发基本上是将外部端口映射到内部地址,因此您的计算机可以与其他网络中的计算机进行通信。 您可以在c#中使用UPnP库,例如Open.Nat ,它支持c#中的端口转发。 (您的路由器应启用端口转发以允许Open.nat工作)。 祝你好运。 Acorrding to your explana...

Udpclient轮询UDP多播地址(Udpclient polling UDP multicast address)

连接UDP套接字是指在接收时将数据报源地址和端口限制为指定对,并在发送时设置默认目标地址和端口。 删除对Connect()调用。 编辑0: 您需要绑定到多播地址,而不是本地IP。 从构造函数中删除localEp ,或者将其替换为多播组/端口对。 请参阅MSDN上的 示例 。 你错了,你只能Receive()一个数据报。 Connecting UDP socket means restricting datagram source address and port to the specified ...

监听多个多播端口(Listen on multiple multicast ports)

您应该能够在不同端口上将侦听器作为作业运行。 但是,您不应该将作业写入同一文件,因为这可能会导致并发写入尝试。 一个更好的方法是将作业写入STDOUT,并让您的启动程序定期从作业中获取输出并将其写入文件: $addr = '224.0.1.75' $ports = ... $sb = { Param( [Parameter(Mandatory=$true)] [Net.IPAddress]$IPAddress, [Parameter(Man...

如何正确设置我的UdpClient以在C#中侦听多播地址239.255.255.250:1900(How do I correctly set up my UdpClient to listen on the multicast address 239.255.255.250:1900 in C#)

好吧,经过多次搜索并将我的头撞在桌子上,我已经把这个东西搞定了。 我以为我昨天有它工作,但它只适用于Windows 7而不适用于XP .. 所以,在这里: IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, Port); UdpClient client = new UdpClient(); client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName...

相关文章

更多

《Spring Security 3》 【第二章】 Spring Security起步(1)

在本章中,我们将要学习Spring Security背后的核心理念,包括重要的术语和产品架构。我们将会 ...

《Spring Security 3》 【第二章】 Spring Security起步(3)

Spring Security的架构在很大程度上依赖代理(delegates)和servlet过滤器, ...

《Spring Security 3》 【第二章】 Spring Security起步(2)

尽管Spring Security的配置可能会很难,但是它的作者是相当为我们着想的,因为他们为我们提供 ...

《Spring Security 3》 【第五章】 精确的访问控制(1)

在本章中,我们将要学习规划应用安全的技术以及用户/组的划分。其次,我们学习两种实现精确访问控制的实现方 ...

怎么用spring security?

我正在学习spring security,看了网上的文档后(下面的附件),动手试了下,结果报错了,不知 ...

《Spring Security 3》 【第三章】增强用户体验(5)

Spring Security框架提供的InMemoryDaoImpl内存凭证存储使用了一个简单的ma ...

《Spring Security 3》 【第一章】 一个不安全应用的剖析

本书的写作遵循了这样的一个开发模式,这个模式我们感觉提供了一个有用的前提来解决复杂的话题——即使用一个 ...

《Spring Security 3》 【第四章】 凭证安全存储(1)

在本章中,我们将会把到目前为止都在使用的内存存储转移到数据库作为后台的认证存储。我们将会介绍默认的Sp ...

《Spring Security 3》 【第三章】增强用户体验(3)

对于经常访问站点的用户有一个便利的功能就是remember me。这个功能允许一个再次访问的用户能够被 ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本