Which one is better for jQuery.ajax calls? .Net Web-Service or an .ashx?
I ahve been practicing jQuery.ajax() recently. I have started to learn to call .Net web-services qith jQuery.ajax(开发者_如何学运维).
Now I am considering if I will use only jQuery.ajax() calls to some service methods on the server; is it still meaningfull to have .Net Web-Services or I should go with .ashx handlers instead?
Thanks!
Two quotes from the ASP.NET forums:
Unless it's an extremely high load situation, you'll find that all three perform nearly identically. The performance of your code inside the handler/service is going to be the limiting factor.
For simple AJAX calls that are only intended to be exposed to the browser, I don't think WCF justifies its added complexity. It's great for some things, but I have a hard time recommending it for this.
Between ASMX and HttpHandler, I go with ASMX every time. An HttpHandler is probably negligibly faster, but an ASMX "ScriptService" makes JSON serialization and deserialization of complex types transparent, which is immensely useful.
Here's another option:
If you have some methods you want to run (and you like JQuery)... I suggest looking at this:
http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/
and related articles. Works beautiful. Very efficient as far as bandwith goes. They also have an article on querying .asmx services.
There is no messing around with the bloated size of ASP.NET's innate AJAX. Since AJAX out of the box can be very bloated. Plus it's very easy.
You should also have a look at microsoft's most recent framework for web services: WebAPI
Personally, I recently switched to ServiceStack.NET for my web services, and I find it's a lot easier and elegant (than WebAPI, or WCF).
a WCF service would be the preferred method over ASP.NET soap web services or ashx services .
精彩评论