<CharlieDigital/> Programming, Politics, and uhh…pineapples

9Jun/08Off

WCF, Prototype, And Awesome-sauce

One of the most awesome features of WCF in .NET 3.5 is support for REST-style AJAX requests to the services.


Rick Strahl has an excellent post on how to get it up and running with jQuery.


Just some notes on working with it myself which I hope can help clarify some some issues:



  • When using POST and the postBody option with Ajax.Request, the format must be {"argument-name":"value"}.  I struggled with this for a while using single quotes and no quotes.  For example: {arg:'hello'}, {'arg':'hello'}, {arg:"hello"} will all result in 400 "Bad Request" errors.
  • The contentType parameter must be set to "application/json".
  • Be sure to decorate the service contract using the WebInvokeAttribute with ResponseFormat and RequestFormat set to WebMessageFormat.Json.

You can download a sample project from here: WcfAjaxSample.zip (3.83 KB)

Posted by Charles Chen

Filed under: .Net, WCF Comments Off
Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

Trackbacks are disabled.