Error - An exception occurred: Credentials are either invalid or unspecified RRS feed

  • Question

  • I update an old key at www.bingsmapportal.com..for a test web page. I probably set this key up 6-9 months ago. I haven't used it in a long time and now what to pick up an old project again.

    I set it up using the following information

    Applicaiton Name: Test

    Application url: http://localhost:50656/WebSite1/TestGeocodeService

    Type: Trial, Public Website

    I created a new web page.

    I add a service reference to

    http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc?wsdl and called it's namesapce GeocodeService.

    On my webform page I have a Button and a label. I have copied the code from http://msdn.microsoft.com/en-us/library/cc966817.aspx

    I do not get any build errors for my page. When I run and press the button I only get the message An exception occurred: Credentials are either invalid or unspecified.

    My code behind looks like this

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    public partial class TestGeocodeService : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
        protected void Button1_Click(object sender, EventArgs e)
        private void MakeGeocodeRequest()
            string Results = "";
                // Set a Bing Maps key before making a request
                string key = "Aox8..Real Key blanked out...pqx";
                GeocodeService.GeocodeRequest geocodeRequest = new GeocodeService.GeocodeRequest();
                // Set the credentials using a valid Bing Maps Key
                geocodeRequest.Credentials = new GeocodeService.Credentials();
                geocodeRequest.Credentials.ApplicationId = key;
                // Set the full address query
                geocodeRequest.Query = "1 Microsoft Way, Redmond, WA";
                // Set the options to only return high confidence results
                GeocodeService.ConfidenceFilter[] filters = new GeocodeService.ConfidenceFilter[1];
                filters[0] = new GeocodeService.ConfidenceFilter();
                filters[0].MinimumConfidence = GeocodeService.Confidence.High;
                GeocodeService.GeocodeOptions geocodeOptions = new GeocodeService.GeocodeOptions();
                geocodeOptions.Filters = filters;
                geocodeRequest.Options = geocodeOptions;
                // Make the geocode request
                GeocodeService.GeocodeServiceClient geocodeService =
                new GeocodeService.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
                GeocodeService.GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest);
                Results = geocodeResponse.Results[0].DisplayName;
            catch (Exception ex)
                Results = "An exception occurred: " + ex.Message;
            lblMessage.Text = Results;

    Monday, November 5, 2012 3:11 PM


  • Trial keys expire after 90 days. you will have to create a new key.


    Monday, November 5, 2012 5:08 PM