Monday, January 24, 2011

Removing the mixed content warning when using Bing Maps API v7.0 over SSL

The other day I was building a store locator for a colleague of mine.  I the application up and running without any issues although when it came time to deploy to production I ran into a problem.  The production environment was being ran over SSL and since the link I used to get the Bing Maps API was not using the HTTPS version I would get a mixed content warning.

Luckily the API documentation from Microsoft recommended a different link.

Here is the one I was using prior to the SSL upgrade:

<script charset="UTF-8" type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

Here is the link I changed it to:

<script charset="UTF-8" type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&ssl=1"></script>

Now the problem is that this still does not work.  As it turns out there is an error in Microsoft’s documentation here.  Here is the correct version:

<script charset="UTF-8" type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1"></script>

Note that the query string parameter at the end of the URL should be s=1 not ssl=1.  Making this caused the rest of the scripts loaded by the Bing Maps API to be delivered over SSL.  This got rid of the mixed content warning.

3 comments: