Simple WCF and AJAX Integration
Tuesday, October 21st, 2008For a long time I have used the ScriptService Attribute with classic ASMX web services to talk with the back end with JavaScript. It is how I turn a web client into an de facto smart client. But I ran into a problem where an object collection I was sending to the server just would not deserialize automatically like it has for me multiple times before. I decided now was the time to move on to WCF/AJAX since I can now freely use .NET 3.5.
I stayed with classic ASMX for a long time mostly because it worked with very little effort. The biggest trouble with WCF is that it gives you so many options which have to be set so precisely or nothing works. It is maddening and pile of documentation you have to go through to get the right answer is overwhelming. A recent video I discovered on Channel 9 showed how to meticulously make a WCF service AJAX friendly. It was a pretty extensive configuration but I found that I needed to enable web sessions (not wcf service sessions) and there was no simple way to do so, until I came across documentation that reminded me about service host factories.

