Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 439
pencilCake Avatar asked Apr 04 '11 19:04

pencilCake


1 Answers

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.

like image 135
Shahin Avatar answered Sep 28 '22 16:09

Shahin