Activate your free membership today | Log-in

Tuesday, April 29th, 2008

Fast Streaming Ajax Proxy

Category: .NET, Performance

Omar AL Zabir, the co-founder & CTO of Pageflakes has written about a continuous streaming Ajax proxy that solves the common problem that all Ajax proxies have, the double delay in downloading content on server first and then delivering to the browser.

Omar talks about the continuous proxy that can help solve the problems. The approach for the continuous proxy is:

  • Read bytes from external server in chunks of 8KB from a separate thread (Reader thread) so that it’s not blocked
  • Store the chunks in an in-memory Queue
  • Write the chunks to ASP.NET Response from that same queue
  • If the queue is finished, wait until more bytes are downloaded by the reader thread

Making a difference

And if you wonder what difference this can make:

Content Proxy served about 42.3 million URLs last month which is quite an engineering challenge for us to make it both fast and scalable. Sometimes Content Proxy serves megabytes of data, which poses even greater engineering challenge. As such proxy gets large number of hits, if we can save on an average 100ms from each call, we can save 4.23 million seconds of download/upload/processing time every month. That’s about 1175 man hours wasted throughout the world by millions of people staring at browser waiting for content to download.

There is even more detail on how the proxy has created.

Posted by Dion Almaer at 7:02 am
Comment here

+++--
3.3 rating from 19 votes

Thursday, April 3rd, 2008

JavaScript, C#, and ExtSharp

Category: .NET, Ext

Colin Ramsay thinks that JavaScript and C# can be scarily similar as he shows an ExtJS example:

JAVASCRIPT:
  1.  
  2. var win = new Ext.Window({
  3.     title: 'Order Viewer', layout: 'border',
  4.     width: 500, height: 500,
  5.     modal: true, resizable: false, closable: false, draggable: false,
  6.     items: [ frm, lst ]
  7. });
  8.  
  9. win.on('render', function() {
  10.     load(5);
  11. });
  12.  
  13. win.show();
  14.  
C#:
  1.  
  2. var win = new Ext.Window{
  3.     Title = "OrderViewer", Layout = Layout.Border,
  4.     Width = 100, Height = 200,
  5.     Modal = true, Resizable = false, Closable = false, Draggable = false,
  6.     Items = new [] { frm, lst }
  7. };
  8.  
  9. win.Render += delegate {
  10.     load(5);
  11. };
  12.  
  13. win.show();
  14.  

This works well for ExtJS since it is written in a style that leads itself to this similarity. Colin also points out ExtSharp, a project that lets you write your Ext application in C#:

I really love Ext but coding in javascript just gives me the chills. So I went out and found a way to use my favorite js library (Ext) and my favorite programming language (C#) at the same time. By using a project called Script# I am able to write C# code and have it converted into javascript, similar to GWT. Building on that, Script# also allows you to code against external APIs, but you need to create the types, methods, properties, etc. for everything in the javascript library. So what I did was write a little console app that parses all of the ExtJS source files extracting out the script comments and writing C# files for each class. The end result is a programmable C# API to access all of the Ext objects and I threw in a couple new things to make life a little easier.

Posted by Dion Almaer at 6:06 am
1 Comment

++++-
4.1 rating from 29 votes

Wednesday, March 19th, 2008

Google Visualization joins the Ajax APIs

Category: JavaScript, .NET, Google

Yoah Bar-David & Itai Raz of Google have introduces the latest Ajax API: Google Visualization API, a new API designed for visualizing structured data.

There is a large visualization gallery that can show you some of the visualizations that you can use.

You tie into the API as you do with other Google Ajax APIs:

JAVASCRIPT:
  1.  
  2. google.load("visualization", "1");
  3.  
  4. var q = new google.visualization.Query(DATA_SOURCE_URL);
  5. q.setQuery("select A, sum(D) group by A");
  6. q.send(responseHandlerCallback);
  7.  

Take a look at this very cool example that the Gapminder team came up with (click on play)

This complements the Google Chart API, which just lifted its limits on the number of calls for charts.

NOTE: Google I/O is a conference being held at San Francisco on May 28-29 2008. APIs like this will be talked about. I will be there. And lots of good folks will be there (Steve Souders, Mark Lucovsky, Guido van Rossum, Jeff Dean, Chris DiBona, Josh Bloch).

Posted by Dion Almaer at 11:56 am
3 Comments

++++-
4.3 rating from 20 votes

Monday, March 3rd, 2008

Json.NET 2.0

Category: .NET, JSON

James Newton-King has quickly released a new version of Json.NET that has a new easier syntax for querying and and creating JSON.

Creating JSON

JAVASCRIPT:
  1.  
  2. JObject o = JObject.FromObject(new
  3. {
  4.   channel = new
  5.   {
  6.     title = "James Newton-King",
  7.     link = "http://james.newtonking.com",
  8.     description = "James Newton-King's blog.",
  9.     item =
  10.         from p in posts
  11.         orderby p.Title
  12.         select new
  13.         {
  14.           title = p.Title,
  15.           description = p.Description,
  16.           link = p.Link,
  17.           category = p.Categories
  18.         }
  19.   }
  20. });
  21.  

Querying JSON

JAVASCRIPT:
  1.  
  2. var categories =
  3.   from c in rss["channel"]["item"].Children()["category"].Values<string>()
  4.   group c by c into g
  5.   orderby g.Count() descending
  6.   select new { Category = g.Key, Count = g.Count() };
  7.  

Check out the project.

Posted by Dion Almaer at 6:11 am
5 Comments

+++--
3.2 rating from 17 votes

Wednesday, February 13th, 2008

AjaxDataControls v1.0 Ajax Extensison for .Net

Category: Ajax, .NET

We've been trying to get more .Net-related content on Ajaxian and luckily we were contacted by the AjaxDataControls team about their new v1.0 release.

The AjaxDataControls is a DotNetSlackers.com's open source project built on top of Microsoft Asp.net Ajax Extension. Currently it contains GridView, DataList, Repeater and Pager controls. The main goal of this project is to provide a similar kind of data controls in the client side which the asp.net developers are already familiar with while working with the server side version. The Server side versions of these controls were developed long before the Ajax came into scene, so there is no client side API which the developer can utilize and it is also not possible to bind data which is returned from a Web Service or Page Method call. On the other hand, AjaxDataControls was specially developed keeping these things in mind. It Provides:

1. Exact same API as the Original Server Side version.
2. Exact same declarative model in aspx page.
3. Full Design time support.
4. Lots of extra features like drag and drop, animation, etc.

It is also possible to use these controls in non-MS platform.

Live examples are hosted:
http://dotnetslackers.com/projects/AjaxDataControls

Source:
http://www.codeplex.com/AjaxDataControls

Forum:
http://dotnetslackers.com/community/forums/71.aspx

Posted by Rey Bango at 9:36 am
2 Comments

+++--
3.5 rating from 40 votes

Tuesday, February 12th, 2008

LINQ to JSON

Category: .NET, JSON

James Newton-King has posted a new bit of code called LINQ to JSON which is a .NET LINQ style API over JSON.

For example, here is how you could get out categories and how often they are used:

JAVASCRIPT:
  1.  
  2. var categories =
  3.   from c in rss.PropertyValue<jobject>("channel")
  4.               .PropertyValue<jarray>("item")
  5.               .Children<jobject>()
  6.               .PropertyValues<jarray>("category")
  7.               .Children<string>()
  8.   group c by c into g
  9.   orderby g.Count() descending
  10.   select new { Category = g.Key, Count = g.Count() };
  11.  

There is also a project, JSLINQ which is an implementation of LINQ to Objects implemented in JavaScript. It is built using a set of extension methods built on top of the JavaScript Array object. If you are using an Array, you can use JSLINQ.

Posted by Dion Almaer at 7:00 am
5 Comments

+++--
3.8 rating from 20 votes

Thursday, January 17th, 2008

CommandProxy: Integrating AIR and .NET

Category: .NET, Adobe

CommandProxy is a proof of concept by Mike Chambers (Adobe AIR team) that offers a solution to a feature that Ben and I have wanted in AIR.... the ability to talk to native code:

Two of the most requested features for Adobe AIR have been the ability to launch native executables from an AIR application, and the ability to integrate native libraries into an AIR application. Unfortunately, neither feature will be included in Adobe AIR 1.0.

However, this does not mean that you cannot build an AIR application that has closer / tighter integration with the underlying operating system. This lower level of integration is possible, but it requires some work on your part. I have put together a proof of concept project, which shows how to integrate Adobe AIR applications with c# / .NET code on any operating system that Adobe AIR currently runs on (Mac and Windows). The project is called CommandProxy. It provides a communication proxy between an AIR application and the underlying operating system and could theoretically work with other web based desktop runtimes (such as Mozilla Prism).

How does it work?

The general concept behind the project is similar to the now defunct Artemis project (which was Java based). The AIR application communicates with the CommandProxy process to communicate and integrate with the underlying operating system. Currently the command proxy supports launching processes (and getting the output from the processes) as well as taking a screenshot of the user’s current screen. However, the framework is built in such a manner that it is possible to add new functionality to the proxy.

The project is opensource and more info is available on the project page on Google Code.

Posted by Dion Almaer at 1:27 pm
3 Comments

++---
2.4 rating from 16 votes

Thursday, September 6th, 2007

Silverlight 1.0 Released: Linux via Moonlight and Expression Encoder

Category: .NET, Microsoft

Microsoft's Silverlight 1.0 has been released.

They seem to be touting the media side of things strongest (a.k.a. Kill Flash):

  • Built-in codec support for playing VC-1 and WMV video, and MP3 and WMA audio within a browser. The VC-1 codec is a big step forward for incorporating media within a web experience - since it supports very efficiently playing high-quality, high definition video in the browser. It is a standards-based media format that is implemented in all HD-DVD and Blueray DVD players, and is supported by hundreds of millions of mobile devices, XBOX 360s, PlayStation 3s, and Windows Media Centers (enabling you to encode content once and run it on all of these devices + Silverlight unmodified). It enables you to use a huge library of existing video content and provides access to the broad ecosystem of existing Windows Media tools, components, vendors and hardware.
  • Silverlight supports the ability to progressively download and play media content from any web-server. You can point Silverlight at any URL containing video/audio media content, and it will download it and enable you to play it within the browser. No special server software is required, and Silverlight can work with any web-server (including Apache on Linux). We'll also be releasing an IIS 7.0 media pack that enables rich bandwidth throttling features that you can enable on your web-server for free.
  • Silverlight also optionally supports built-in media streaming. This enables you to use a streaming server like Windows Media Server on the backend to efficiently stream video/audio (note: Windows Media Server is a free product that runs on Windows Server). Streaming brings some significant benefits in that: 1) it can improve the end-user's experience when they seek around in a large video stream, and 2) it can dramatically lower your bandwidth costs.

But there is also the Ajax (or Kill Ajax?) side:

  • Silverlight enables you to create rich UI and animations, and blend vector graphics with HTML to create compelling content experiences. It supports a Javascript programming model to develop these. One benefit of this is that it makes it really easy to integrate these experiences within AJAX web-pages (since you can write Javascript code to update both the HTML and XAML elements together.?).

As well as putting out a final version (which will be nicely auto-updated), there was also the announcement that Miguel de Icaza's, and his team at Novell, are now officially the Linux solution via Moonlight.

Microsoft already announced Silverlight 1.1 with all of the goodness of the DLR, so a lot of people are just waiting for that!

Posted by Dion Almaer at 12:03 am
15 Comments

++++-
4 rating from 33 votes

Tuesday, July 3rd, 2007

Ajaxed: Ajax for classic ASP

Category: JavaScript, Library, .NET

Are you writing classic ASP pages and want to join in the Ajax revolution too? Really? Well, Ajaxed is for you. The framework is simialr to xajax for PHP, in that it allows you to tie in to a named function on th eserver side.

It looks like this:

JAVASCRIPT:
  1.  
  2. <!--#include virtual="/ajaxed/ajaxed.asp"-->
  3. <%
  4. set page = new AjaxedPage
  5. page.draw()
  6.  
  7. sub init() : end sub
  8.  
  9. sub callback(action)
  10.     if action = "add" then page.return(add(page.RF("a"), page.RF("b")))
  11. end sub
  12.  
  13. function add(a, b)
  14.     if not isnumeric(a) then a = 0
  15.     if not isnumeric(b) then b = 0
  16.     add = cint(a) + cint(b)
  17. end function
  18.  
  19. sub main() %>
  20.  
  21.     <script>
  22.         function added(sum) {
  23.             $('c').value = sum;
  24.         }
  25.     </script>
  26.  
  27.     <form id="frm">
  28.         <input type="Text" name="a" id="a"/>+
  29.         <input type="Text" name="b" id="b"/>=
  30.         <input type="Text" name="c" id="c"/>
  31.         <button onclick="ajaxed.callback('add', added)" type="button">calculate</button>
  32.     </form>
  33.    
  34. <% end sub %>
  35.  

Posted by Dion Almaer at 4:40 am
36 Comments

++++-
4.3 rating from 82 votes

Tuesday, June 5th, 2007

Freshlogic Studios Folders

Category: .NET, Showcase

Jacob DuBray and Freshlogic Studios have a new Ajax application out in the wild:

Folders allows you to work with your files on the internet, the same way you work with them on your desktop. We've turned months of research and development into a simple, modern website that allows you to upload, manage, and share your digital photos, music, movies and documents with your friends. Upload your files, browse through your friends' folders, even search to see what other people are sharing.

Folders also has RSS syndication built right in, giving you what we call "one-click podcasting". Easily evangelize your thoughts and ideas to the world.

Freshlogic Folders

Posted by Dion Almaer at 6:24 am
15 Comments

+++--
3.3 rating from 36 votes

Friday, May 25th, 2007

Profile Mine: Rich Ajax MySpace Editor

Category: .NET, Showcase

Don Schmitt and his team has built a site using Microsoft’s Ajax extensions and
Ajax control toolkit called Profilemine.

Profilemine has a unique MySpace profile editor that enables you to edit
your actual profile without typing HTML code (not just the CSS).

The site includes a number of advanced Ajax-based features such as:

  • Load your existing profile and edit it directly (and not just the styles).
  • Automatic layout change submissions directly to your MySpace profile
    without requiring copy / paste.
  • Ability to drag & drop elements on your profile.
  • Ability to upload layouts and the site will automatically take a snapshot
    of the layout and create the thumbnail and the layout will be available for
    download immediately.
  • Upload images directly to the front page of your profile without writing
    any code.
  • Save your favorite layouts and easily swap between them.

Profile Mine

Posted by Dion Almaer at 5:51 am
12 Comments

++---
2.7 rating from 35 votes

Wednesday, May 23rd, 2007

MS.Services: A .NET AJAX Data provider

Category: .NET

MSServices is a server-side data processing application for HTTP (AJAX Data provider). It can execute Database SPs, MSMQ, Assemblies, IronPython script and generates JSON, Web Service, Text, Excel or RSS file through HTTP. The system has authentication/authorization, caching, compression and logging support.

This allowed you to access URLs such as http://localhost/Web/Northwind.GetCustomerOrders.ws?CustomerID=ALFKI from your Ajax applications.

Posted by Dion Almaer at 6:04 am
10 Comments

++++-
4.3 rating from 35 votes

Tuesday, May 1st, 2007

Jayrock: JSON and JSON-RPC for .NET

Category: JavaScript, .NET, JSON

Jayrock is a modest and an open source implementation of JSON and JSON-RPC for the Microsoft .NET Framework, including ASP.NET. What's so modest about it? Well, modest as in plain and basic and no work of genius.

A developer creates a helloworld.ashx that contains your server side logic:

C#:
  1.  
  2. <%@ WebHandler Class="JayrockWeb.HelloWorld" %>
  3.  
  4. namespace JayrockWeb
  5. {
  6.     using System;
  7.     using System.Web;
  8.     using Jayrock.Json;
  9.     using Jayrock.JsonRpc;
  10.     using Jayrock.JsonRpc.Web;
  11.  
  12.     public class HelloWorld : JsonRpcHandler
  13.     {
  14.         [ JsonRpcMethod("greetings") ]
  15.         public string Greetings()
  16.         {
  17.             return "Welcome to Jayrock!";
  18.         }
  19.     }
  20. }
  21.