How to convert a street address to longitude and latitude (geocoding) via web services (Google)

Google AdSense

Several years ago, I wrote a blog entry detailing how to use (and Yahoo!) web services to geocode an address. Since then both web services have changed a little and I found myself needing to update my code to support non-US locations. Below is sample code showing how to use Google’s Geocoding web service to get longitude and latitude values for addresses.
Continue reading

How to append options to CascadingDropDown after initially populated via AJAX Web Service

Google AdSense

The setup: Microsoft ASP.NET and AJAX Control Toolkit components

I needed to add additional dropdown options to a DropDownList web control in use by the Ajax Control Toolkit CascadingDropDown ASP.NET AJAX extender. The CascadingDropDown provided a means to get an automatic population of a set of options called by the web service. This AJAX call also passes in the parent item, so that the list items cascade (show items related to the parent control).

An example could be 2 drop down lists: Automobile Make and Automobile Model. If the user selects “Ford” from the Automobile Make drop down list, then only Ford models are listed in the Automobile Model drop down list. If the user changes the Automobile Make to “Honda”, then the items in the Automobile Model changes to show only Honda models.

I needed a way to append an “All” option to the drop down list, but I didn’t want to automatically include “All” as valid option in my Web Service. I wanted to append it on a specific form rather than as part of the data feed.

To start, you need to have a working set of CascadingDropDown web controls. I’m not to explain that set up, because you need to figure out that before you can add additional elements.

Continue reading

Troubleshooting HTTP 401.1 errors called from localhost

In troubleshooting a web service for another system to connect to one of my systems, I created a simple web service test client. This test client was a WinForms app that executed the web services and rendered the XML display and data in a DataGrid.

The test client app worked fine from my laptop and another server, however, when I tried to run it from the web server (that hosted the web services), I began receiving 401.1 errors.

HTTP 401.1 – Unauthorized: Logon Failed

Below are the 401.1 error details captured in the system’s event log:

Event Type: Failure Audit
Event Source: Security
Event Category: Logon/Logoff
Description: Logon Failure:
Reason: An error occurred during logon
Authentication Package: NTLM
Status code: 0xC000006D

Continue reading

How to render a ASP.NET User Control within a Web Service and return the generated HTML

My needs:

  • Use ASP.NET AJAX PopUpExtender control to provide a mouseover popup with additional content relevant to the GridView row.
  • Use DynamicContextKey to pass in GridView record’s unique identifier.

My wants:

  • Use a User Control to render the HTML response, so I don’t need to build the HTML code using a StringBuilder or HtmlTextWriter.
First attempt

My initial code was something similar to the below code:

Continue reading