[Sample Code] My TravelNews Mashup Site

I get so many requests for this code after I've done an ASP.NET AJAX session that I decided I had to find some way to host sample code (rather than set up a separate file transfer for each individual request which was getting a bit painful). So with a bit of tweaking, I managed to get something akin to a suitable disclaimer on the download area on Community Server (my hoster doesn't give you access to the Community Server files if you opt for their easy-to-use "create me a Community Server" site option. With hindsight I should perhaps have spent the time setting it up myself).

So, before downloading you will be asked to acknowledge that this is demo code. It is untested. It does bad things. You shouldn't use it as a pattern to design your enterprise wide payroll system. It may corrupt you. It may very well give you nightmares. Yadda yadda yadda. You have been warned.

What is it? Just a simple demo I usually show early on in an ASP.NET AJAX demo:

  • It uses the traffic service at backstage.bbc.co.uk to get information about traffic problems across the UK
  • It presents that data on a map using Virtual Earth with pushpins representing hold-ups. The pushpins are colour-coded by severity and you can hover over a push-pin to see details of the incident
  • What does it illustrate?
    • How few lines of code are required in ASP.NET AJAX to actually build something pretty cool
    • How easy it is to call a web service from client-side JavaScript with ASP.NET AJAX
    • That allows me to do my XML parsing in managed code in the web service (much easier for me than writing in JavaScript) and take advantage of ASP.NET caching too
    • ASP.NET AJAX takes care of dynamically generating the proxies to call the web service and also serialising / deserialising the request / response data
    • All in all it's about 50 lines of C# code in the web service and maybe 30 lines of JavaScript code on the client

To see what it looks like in action: TravelNews Mashup Link

And if you want to download the source code: Download Link

Technorati tags: asp.net, ajax, mashup, backstage.bbc.co.uk