Click here to Skip to main content
15,117,318 members
Articles / Web Development / ASP.NET
Posted 7 Dec 2006


16 bookmarked

Zeta Tiny Url Web Service

Rate me:
Please Sign up or sign in to vote.
3.95/5 (14 votes)
7 Dec 2006CPOL3 min read
Introducing a web service to generate short URLs from long URLs

Image 1


This article presents you a programmatic way to generate a short URL from a long URL. This is especially useful when you want to send e-mail messages (or even instant messages) to others and want to avoid the clients to break long URLs into multiple lines, thus rending them unclickable.

E.g. a long URL could be

And a short URL generated from this long URL could be

To read a more detailed description, please see

The basics of services like is that they keep a simple dictionary (also called "hash table" or "associative array") that stores the short URL as the key and the long URL as the value of an entry in the dictionary. When you enter the short URL into your web browser, a lookup is done and a redirect is executed to the long URL.

For instant testing the code of this article, visit

What the web service does

The web service I've written is simply a wrapper to It has one simple method to call:

string MakeTinyUrl( string longUrl );

You pass a long URL and get a short URL. That's it.

Behind the scenes

The download as of now contains not one backend, but two:

1.) Interface to

This was my first implementation. Since does not offer a programatic way to access the service, I basically do a HTTP post to the site and then screen-scrapping the results with some Regular Expressions.

That of course means that I must adjust the code whenever the guys change their output HTML.

2.) Interface to

Fortunately, this week, my co-worker Rainer Bendig registered the domain (Since you don't know Rainer, to sum up, he is the guy that constantly buys and sells domain names - in our office he is already infamous for registering more domains per day than he answers customer support calls :-).

At this domain, Rainer provides the same functionality than but also accessible as a web service. I enhanced my application so that you are now able to switch to by simply changing a configuration value in the Web.config file.

Effectively you can now use my web service to access another web service, but with a consistent interface. If I add more alternatives in the future, the web service that is presented to the consuming code still stays constant, because the calles to the different services happen in the backend.

Points of Interest

Special topics covered in the code include:

Enjoy the web service! And as always, please post your comments, questions, bug reports or worships in the comment section below. I really do appreciate your feedback!


  • 2006-12-07: First version created.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Uwe Keim
Chief Technology Officer Zeta Producer Desktop CMS
Germany Germany
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.

In his free time, he does climbing, running and mountain biking. Recently he became a father of a cute boy.

Some cool, free software from us:

Deutschsprachiges Forum zu Elektromobilität und Tesla  
Windows 10 Ereignisanzeige  
German Developer Community  
Free Test Management Software - Intuitive, competitive, Test Plans. Download now!  
Homepage erstellen - Intuitive, very easy to use. Download now!  
Send large Files online for free by Email

Comments and Discussions

GeneralMy vote of 1 Pin
PeaceTiger11-Jun-09 0:21
MemberPeaceTiger11-Jun-09 0:21 
GeneralSorry but ..... Pin
mbaocha6-May-09 18:31
Membermbaocha6-May-09 18:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.