Contents tagged with Ajax

  • Google Chrome and Facebook...

    googlechrome ...is just not working as it should. There are major Ajax problems in that browser. I know, it came out like this week, but they talk much about the rigorous testing they go through and how Chrome should work well on popular sites. Well Facebook should count as quite popular I guess.

    I'm sure it'll be fixed very quick, and other than that - the browser seems to work pretty well. The UI feels clean and bare-bone, and occationally it feels somewhat faster.

    I like the Google Chrome story they made, very cool.

  • Returning Json from RESTful Interface with WCF

    WCF2 Someone commented on an earlier blog post I did on REST, POX/POJO and WCF and the comment read:

    How about REST WCF bits from .NET 3.5 SP1? Is it possible now to let the user decide in which format he wants the response (xml or json) like MySpace API for example?

    The convention is to use a file like extension at the end of the resource to specify data return type (.xml or .json)

    api.myspace.com/.../details.xml

    api.myspace.com/.../details.json

    UPDATE/EDIT: Turns out I was doing this the hard way as there is support for json serialization right from the ServiceContract which makes this extremely easy. Just make sure to specify the ResponseFormat to be json. In a previous "version" of this blog post, I used the JavaScriptSerializer class, which is... dumb :)

    First go take a look at the sample that Kirk Evans had on his blog.

    Note that it may be easier to create a RESTful interface with ASP.NET MVC if you're into that tech, but that's another blog post.

    So, first I'm modifying the REST interface somewhat, adding support for /details.xml and /details.json URI:

    [ServiceContract]
    public interface IService
    {
        [OperationContract]
        [WebGet(UriTemplate="customers/{id}/details.xml")]
        Customer GetCustomer(string id);
    
        [OperationContract]
        [WebGet(UriTemplate = "customers/{id}/details.json", 
    ResponseFormat=WebMessageFormat.Json)]
    Customer GetJsonCustomer(string id); }

    As you can see, on the GetJsonCustomer() method, I'm specifying the ResponseFormat to be json. That's it :)

    A sample implementation for this interface looks like this:

    public Customer GetCustomer(string id)
    {
        return new Customer { ID = id, Name = "Demo User" };
    }
    
    public Customer GetJsonCustomer(string id)
    {
        return GetCustomer(id);
    }

    Using Fiddler to simulate client request and see what comes out of our RESTful service, we get this result from the /customers/123/details.xml request:

      <Customer xmlns="http://schemas.datacontract.org/2004/07/RESTfulWCF" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ID>1</ID><Name>Demo User</Name></Customer>

    ...and this from the /customers/123/details.json request:

      {"ID":"123","Name":"Demo User"}

  • New Stuff, New Stuff, Go Download Already

    First of all you got the VS 2005 Service Pack 1 for Team Suite, and it's said to contain some 2200 fixes?!?! It's available for download here. Note that it's a 430 MB download and it's also said to take some time to install.

    Second good thing, and also a must to download and check out, is the RC1 of ASP.NET AJAX. You can read about it on Scott's blog. As usual, Scott gives you the info you need. I'm pretty sure that this package will used ALOT in the next couple of years, until something else pops up or becomes "cooler". Perhaps WPF(e) will beat it eventually, Another thing - the ASP.NET hompage news also says:

    The Microsoft AJAX Library is also available in an easy-to-install, standalone package for development on non-Windows systems. 

    Sounds interesting, don't you think? You can download and read more about ASP.NET AJAX on their webby,

  • [Ajax] Top 10 Web 2.0 Attack Vectors

    Shreeraj Shah on Top 10 Web 2.0 Attack Vectors:
    This technological transformation is bringing in new security concerns and attack vectors into existence. Yamanner, Samy and Spaceflash type worms are exploiting “client-side” AJAX frameworks, providing new avenues of attack and compromising some of the confidential information.
    Worth reading I say. Especially #6, Client side validation in AJAX routines:

    WEB 2.0 based applications use AJAX routines to do a lot of work on the client-side, such as client-side validations for data type, content-checking, date fields, etc. Normally, these client-side checks must be backed up by server-side checks as well. Most developers fail to do so; their reasoning being the assumption that validation is taken care of in AJAX routines. It is possible to bypass AJAX-based validations and to make POST or GET requests directly to the application – a major source for input validation based attacks such as SQL injection, LDAP injection, etc. that can compromise a Web application’s key resources.

    This is just not a common mistake in Ajax code, it relates to all web pages and forms where you leave input validation to be handled by JavaScript on the client side. If you're concerned with what data you get fed by people, always check it on the server side. And not just data from form fields, also check data you get via web services, POX over HTTP or even the product catalog you import from trusted parts.

     
  • [Ajax] GWT - Google Web Toolkit

    Related to what I wrote in my previous post about Script#, there is already GWT - Google Web Toolkit, which does something similar but with Java. You write your front end in the Java language, and the GWT compiler converts the code into JavaScript and HTML.
  • [Ajax] Check Out the Script# Prototype

    This should interest all of you who are into AJAX, Atlas and that kind of stuff no the ASP.NET platform - Nikhil (who is an architect on the Web Platform and Tools team at Microsoft) releases a prototype of a C# to Javascript/Ajax compiler and looks for feedback:

    Script# brings the C# developer experience (programming and tooling) to Javascript/Ajax world. This post shares a prototype project for enabling script authoring via C#...

    Check it out - Nikhil also got a video to explain how it works.

  • [Ajax] Check Out the "Atlas" Control Toolkit

    You may want to look at the "Atlas" Control Toolkit site where they have a list of cool samples of what you can do with it, and it's dead simple. You can probably live without some of the controls, but some of them are quite useful and you would have to spend quite some time to achieve the effects you get for free. My favos on that list are the CollapsiblePanel and the TextBoxWatermark.

    Some may argue that these controls have nothing to do with Ajax, but Ajax has become synonymous with a rich UI, and this is what "Atlas" gives you for sure.