VEMap.Find Returns Italian Location from US Addresses (Los Angeles)?

This one took me a couple of minutes to figure out, so I thought I’d pass it along. Recently I launched an update to an application (in beta) that used the VEMap.Find method to geocode addresses in Los Angeles, CA, but for some reason the results for a few of the addresses would show up somewhere in Italy. Eventually I noticed that this was only happening for avenues (as opposed to streets or boulevards). I realized that our street database used the abbreviation “AV” instead of “AVE” and deduced that there must be an Italian province (Avellino?) that used that abbreviation and the parsing engine behind VEMap.Find must pick that out before the zip code.

My solution was to replace the word “AV” with “AVE” in the address string before passing it to the VEMap.Find function with the following:


So far, so good. I wonder how may more calls to replace I’ll end up daisy chaining on to that before I’m through with this one… – Iteration 3: MVC Membership Provider-based Access Control

In my previous post in this series, I determined that I had to start looking into how MVC handles access control before moving forward. I came up with a list of functional specifications that I needed to write proof of concept code right away to learn how ASP.Net MVC helps (or hinders) me in implementing access control. In this post, I’ll look at the first 2 specifications:

  1. Authenticate individual users and mange their credentials (i.e. a MembershipProvider)
  2. Manage access to functionality based on membership (i.e. a MembershipProvider)

I know that in MVC, controlling access to controller actions (and thereby the associated views) is done via a specific type of ActionFilter called an AuthorizationFilter. Also, the ASP.Net MVC Web Application template includes code that shows how to use an ASP.Net membership provider to enable user registration and login. So, a quick test that will tell me if the built-in AuthorizationFilter will be able to meet the first 2 functional specifications above is to add an authorization filter to the Add action of the Workouts controller so that only users that have logged in will be able to add a workout.

I do this by changing the attribute for the Add method from:



AcceptVerbs(HttpVerbs.Get), Authorize()

Now when trying to add a workout, a user is redirected to the login page. After registering and logging in the user is now able to add workouts!

In the next installment I will try to convince myself that I can control access to actions based on user’s relationship to an entity (i.e. members can only delete their own workouts).

Stay tuned… – Iteration 2: User Stories

Creating User Stories

Now that I’ve got a feel for how MVC handles the mechanics of a data-driven application, I’ve got to take a step back and think about how users are going to use the application. For a start, here’s what I came up with:

  • The site will allow anyone (both anonymous and logged in users) to view all recently logged workouts.
  • The site will allow users to create an account and thereby become members.
  • Members will be able to log their own workouts.
  • Members will be able to add events that they are training for.
  • Members will also be able to join one or more teams. A team is a group of members (e.g. that may train together or who are training for the same event).
  • Teammates (members of the same team) will be to see each others’ complete workout logs
  • Teammates will be able to subscribe to updates (i.e. via a feed, e-mail alerts, or iCal) to the logs of their teammates.
  • Only certain members will be able to create, own, and manage a team.

I’m sure these and other stories will get more flushed out as the project evolves, but that’s plenty for now.

Turning Those Stories into Specifications
From these stories I’ve derived some entities (the nouns) that I’ll be working with:

  • Member – a user with an account
  • Workout – um, a workout
  • Event – a race (10K, marathon, triathlon, etc) that a member is training for
  • Team – a group of members

I can see from these stories that the application will need to be able deliver certain functionality that I haven’t yet implemented in MVC. Specifically, the application will need to:

  1. Authenticate individual users and mange their credentials (i.e. a MembershipProvider)
  2. Manage access to functionality based on membership (i.e. a MembershipProvider)
  3. Manage access to functionality based on the user’s relationship (i.e. “owner”, or “teammate”) to a particular entity (workout, member, team, etc)
  4. Manage access to functionality based on roles (i.e. a RoleProvider)
  5. Return content in multiple formats (HTML, rss, iCal???)

That all looks like pretty vanilla stuff for a WebForms application, but I’ll have to convince myself that it will all work out in the MVC world.  So it’s time to write some proof of concept code to convince myself I won’t get stuck.

Stay tuned…

T4 Slays Spaghetti Monster

My client wanted a list of all of the tables and their respective columns in a given SQL server database.  My first instinct was to get Visio to create an ER diagram by reverse engineering the database. However, with dozens of tables in this database, the diagram that Visio spit out looked like spaghetti and meatballs, and would have printed across 36 8.5″x11″ pages. That said, Visio did a better job laying out the diagram than I would have by hand.

Then I thought, what if I had an automated way to create a document that listed the tables in alphabetical order, showing all of their columns? This list would be something that the client could cross-refrence against the spaghetti monster. Well, thanks to T4, I do have such an automated way. I spent my lunch break hacking away (it’s scary to see how much you rely on Intellisense once you don’t have it) at this simple template that will iterate through all the tables in a database and output all the columns for each as a text file. To get it work,follow these steps:

  1. Download the template file (
  2. Copy it to any Visual Studio 2005/2008 project.
  3. Open it, replace “[your connection string here]” with a valid SQL Server connection string (ideally to a database with a limited number of tables), and then save the file.

Visual Studio attempts to generate the output whenever you save the template file, so the new text file should already be generated.  To view it, go to the Solution Explorer window and expand the node for and you will see a file named all_table_columns.txt. Open that text document and you should have a list of all tables and columns!

For more on code generation via T4, see Scott Hanselman’s link-fest of a post. – Iteration 1: Completing the Workout Life Cycle

So, if you read my first post in this series, you know I’m creating a MVC web application to log and share workouts. Picking up where I left off, I’ve got to complete the life cycle of a workout (insert, select, update, and delete).

Completing the Life Cycle of a Workout

In the first post we covered adding a new workout, and selecting recent workouts. That leaves updating and deleting workouts. To save time we’ll just implement the delete functionality and leave updating for later. To enable deleting all I had to do was add a controller action that would perform the delete operation against the database and add forms to the default view that would post to this controller action.

The new controller action in WorkoutsController.vb:

Note that the action only accepts HTTP POST requests and that it expects the MVC framework to map an input value to a local integer variable called workoutId which it then uses to query and delete the workout record in the database.

The new forms (one for each row) in Index.aspx:

Delete Workout Form

This will write a form that contains a delete button and hidden input for the WorkoutId for each row in the table. Clicking on the Remove button on any row will delete the record and redirect the user back to the home page. You can try it out here:

Wow, that was easy and I was able to implement it in about a dozen lines of code or so. I <3 MVC.

In my next iteration, I’ll create some user stories to see what direction I need to go from here. I know, I know, this is a little backwards. I probably should have started with pen and paper (and what of unit tests???) and then gotten into the code, but MVC is new to me, and I needed to write some code just to understand the life cycle of a page. Besides, better late than never, right?

Stay tuned…

My First ASP.Net MVC Application –

I’ve been very excited about ASP.Net MVC ever since I started hearing about its emergence in various blogs and podcasts. MVC basically addresses all of the issues I have with developing ASP.Net web sites (viewstate, postbacks, testing, etc), and I’ve eagerly awaiting a release its release.

Well, now that ASP.Net MVC is in it’s first beta, I thought it was time to jump in and get my hands dirty with some code. All I needed was an idea for a demo app. My brother-in-law was telling me that he needed an application to log his progress and help motivate him to train for an upcoming marathon. Specifically he said that there are lot of sites out there that allow you to log your own training, but he was really interested in one that would emphasize sharing your logs with your training partners as means to help keep each other motivated. So I started working on a small web application that enables users to log and share their workouts when training. You can follow along as I develop it at:

Iteration 0: Setting Up the Development Environment

To do create this application on my dev machine, I would need to install ASP.Net MCV Beta (as well as VS 2008 SP1).

I’d also need to find a hosting service that would allow me to host and MVC application (I went with, and to that end, these threads were helpful:

  1. Step by step instructions for configuring your hosting environment:
  2. Which assemblies you’ll need to include in the /bin folder:

Iteration .5: Putting Something Out There

By coincidence (I swear) Stephen Walther and Paul Litwin create a workout log application in their ASP.Net MVC video series. As a first iteration, I thought it would be a good idea to basically go through this series step by step and publish the output on my new hosted. After walking through the steps in the videos, I modified the pages slightly to use the site’s master page, which I also modified a bit to handle navigation for the newly added pages.

You can see the results at:

Coming Soon… Iteration 1: Completing the Workout Life Cycle

Creating an app that adds and displays data in just a couple of hours (thanks to the help of the template code and tutorials) isn’t too shabby, but there’s lot’s of work to be done. For starters, I want to be able to complete the life cycle of a workout (insert, select, update, and delete). So I’ll do that next.

After that it’s time to take a step back, and review the user stories to get a firm idea of what the app will need to be able to do – this is where my path will diverge from the good start set out by Walther and Litwin. With the big picture in mind, I’ll be able to layout the subsequent iterations that will allow me to get the app fully functional in time to help my brother-in-law train for his marathon.

Stay tuned…

The Missing LINQ (to Oracle)

Since all the .Net applications I am currently working on use Oracle on the back end, I haven’t spent a lot of time looking into LINQ – LINQ to SQL only supports SQL Server. After attending the 2008 launch event and getting a chance to put my hands on some LINQ examples in the labs I didn’t get the feeling that I was missing much. I currently use SubSonic as a means of automating the creation of an abstraction layer between my UI code and the database, and I love it. I’ve been considering it a bridge that will last me at least until LINQ to Entities comes out later this year, at which point I’ll have to evaluate the pros and cons of each. Scott Hanselman’s recent interview with Mike Pizzo provides a great in-depth analysis of the differences between LINQ to Entities and LINQ to SQL. As with any abstraction layer, performance seems to be the question on everyone’s mind. It would be great to see benchmarks of the same queries of the same database for both Linq to SQL and Linq to Entities. Which brings me to my point, I would love to see a Linq to Oracle. I’m sure Oracle is on board to create a provider for the Entity Framework, and I know the EF provides added value (mapping entities to multiple tables, and vice versa), but I would also like to see Oracle provide an implementation of the IQueryable interface that is lean and mean for simple applications. In the mean time, I think I’ll check out the DbLinq Project, which claims to provide LINQ implementations for databases other than SQL Server. I was going to look into this when I first started using SubSonic, but I saw the Nov 07 update that said the Oracle Provider was no longer supported. Still, it’s probably worth downloading and comparing.

Posted in Uncategorized | Tagged , , , | Comments Off on The Missing LINQ (to Oracle)

Google Calendar Sync for Outlook

A couple of days ago Google released Google Calendar Sync for Outlook.  It’s free, so I downloaded it and gave it a test drive.  In summary, it’s not ready for prime time… yet.  It’s major limitation is that (unlike Google Sync for your Blackberry which allows you to choose which of your calendars to sync) it will only sync your primary calendar.  Also, unlike GSyncIt ($10), you cannot choose which Outlook calendar you want to sync with.  Once Google overcomes these limitations, I’m sure it will be a superior product to any competitor’s and of course, well worth the price. Slide Show

My client, Terra Nova Pools, wanted to add a new page to their site that would display a looping slide show of before and after pictures of their clients’ pools. I decided to implement this page using this solution that relies on the javascript library to fade a series of div tags in and out sequentially. The solution worked well with the exception of one small glitch – the screen seemed to jump between slides in FireFox (see comments on page above). I solved this by setting the position attribute for all slide divs to absolute with the following line of css:

div.slide { position: absolute; }

You can see the results at:

I chose this solution because I knew I could rely on the library to support a wide array of browsers as well as allow me to use web standards to ensure that the page would degrade nicely for users on mobile devices or older browsers. I had previously used Dynamic Drive’s ultimate fade in javascript slide show for the site’s home page, but that did not work at all in Safari and required defensive coding to be able to degrade nicely.