This project is read-only.

The WebBuddy Manifesto

(or "What is WebBuddy"?)
Face it, getting your Silverlight Application talking with your web servers can be a bit of a pain. You have to muck with WebClient, build your REST query strings by hand, handle System.IO.Stream's containing JSON strings, and basically have a bad day. Sure it might be easy for those guys running ASP.NET--they just do some magic in Visual Studio and everybody is happy, but your application stack is Ruby, Perl, or PHP. Visual Studio gives you no love, the .NET library has nothing for you, and every wiz-bang example you find assumes you are talking with ASP.NET. It's high time calling your web services with Silverlight is as easy as it is with JavaScript!
Now with Dog
WebBuddy offers a growing plethora of quick-and-dirty utilities to make AJAX easy. UriBuddy makes manipulating query strings easy with a Dictionary. AjaxBuddy lets you make AJAX calls using strongly typed callbacks which will pass back your deserialized data.

Get Started

WebBuddy Overview

  • AjaxBuddy - A library that attempts to make AJAX calls feel more like jQuery or Prototype.js.
  • UriBuddy - Makes handling query parameters easy. No more string concatenation!
  • JsonBuddy - (comming soon) Paste a JSON string, click some buttons, and get a bunch of strongly typed C# classes to use for serialization.


Call your backend and AjaxBuddy will call you back with a strongly typed result!
View a Full Sample
public void MakeQuery()
    string requestUrl = "";
    // Ask Yahoo about snow in Seattle and call us back with the strongly typed results...
    Dictionary<String, String> query = new Dictionary<string, string>
        {"query","Snow In Seattle"},
    AjaxBuddy buddy = new AjaxBuddy();
    // Notice how this looks kinda like jQuery?  Notice how there isn't any fuss with WebClient?
        new Uri(requestUrl),
        new AjaxOptions<TResponseType>
            Callback = queryCallback,
            State = "my user state",
            FailureCallback = failureCallback
// This is our callback when the AJAX request has completed.  Notice it passes in a strongly
// typed result?  Nice, huh?
private void queryCallback(YahooImageResult queryResults, object userState)
    Console.WriteLine("Got back {0} results", queryResults.Results.totalResultsReturned);

// This is our callback when the AJAX request has barfed on our shoes.  Exception contains
// the exception passed in by WebClient
private void failureCallback(Exception exception, object userState)
    Console.WriteLine("Barf: {0}", exception);



Use a Dictionary<> to hold your parameters. Let us turn them into a properly escaped string.
// Take a base url
Uri sample = new Uri("");

// some highly useful parameters
Dictionary<String, String> query = new Dictionary<string, string>
    {"param2","code man"}


// create a new url using a chained style of coding
Uri newSample = sample

// or do something like this
Uri somewhereElse = sample.AppendPath("pages")

// prints:

// turn the dictionary into a string with our famous extension method
String queryString = query.ToQueryString();

// prints: param1=nice&param2=code%20man

Notice: Project is under construction. Code may not work as intended--patches are welcome. No purchase necessary. Actual cash value: $0.01. Rules and free game pieces available on the web. Offer void where prohibited by law. May contain peanuts.

Last edited Mar 31, 2009 at 10:02 PM by coryking, version 22