I’m happy to announce that with Q1 2009 release of RadControls for ASP.NET AJAX (Telerik.Web.UI) you will be able to compress the response from ADO.NET DataServices (formerly "Project Astoria") in Silverlight web applications with simple web.config registration:


  <addname="RadCompression" type="Telerik.Web.UI.RadCompression" />

Here is the result for Northwind Customers with ATOM and JSON response type:


ATOM : Bytes Received: 11,623 (uncompressed 92,848)
JSON  : Bytes Received:   9,237 (uncompressed 39,460)

I’ve made small Silverlight application to illustrate the new feature – two instances of RadGridView bound to Northwind Customers using ADO.NET DataService:

The first grid is bound using the traditional Silverlight ADO.NET DataService approach with DataServiceContext:

private void BeginATOMRequest()
    DataServiceContext context = new DataServiceContext(new Uri("WebDataService1.svc", UriKind.Relative));
    DataServiceQuery<Customers> query = context.CreateQuery<Customers>("Customers");
    query.BeginExecute(ATOMRequestCompleted, query);

private void ATOMRequestCompleted(IAsyncResult asyncResult)
    DataServiceQuery<Customers> query = asyncResult.AsyncState as DataServiceQuery<Customers>;
    RadGridView1.ItemsSource = query.EndExecute(asyncResult).ToList();

and the second grid is bound using pure asynchronous WebRequest with JSON response:

private void BeginJSONRequest()
    Uri documentUri = HtmlPage.Document.DocumentUri;
    Uri uri = new Uri(String.Format("{0}://{1}:{2}/{3}", documentUri.Scheme, documentUri.Host, documentUri.Port, "WebDataService1.svc/Customers"), UriKind.Absolute);

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
    request.Method = "GET";
    request.Accept = "application/json";
    IAsyncResult result = request.BeginGetResponse(new AsyncCallback(JSONRequestCompleted), request);

private void JSONRequestCompleted(IAsyncResult result)
    HttpWebRequest request = (HttpWebRequest)result.AsyncState;
    HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);

    List<Customers> list = new List<Customers>();

    using (Stream stream = (Stream)response.GetResponseStream())
        JsonValue items = JsonArray.Load(stream);

        foreach (KeyValuePair<string, JsonValue> item in items)
            if (item.Key == "d")
                JsonArray array = (JsonArray)item.Value;

                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Customers));

                foreach (JsonObject child in array)
                    using (MemoryStream jsonStream = new MemoryStream(Encoding.Unicode.GetBytes(child.ToString())))
                        Customers customer = (Customers)serializer.ReadObject(jsonStream);

    Dispatcher.BeginInvoke(() =>
        RadGridView2.ItemsSource = list;



About the Author

Vladimir Enchev

is Director of Engineering, Native Mobile UI & Frameworks