我最近一直在练习 jQuery.ajax()。我已经开始学习调用 .Net 网络服务 qith jQuery.ajax()。
现在我正在考虑是否要仅 jQuery.ajax() 调用服务器上的某些服务方法;使用 .Net Web 服务是否仍然有意义,或者我应该改用 .ashx 处理程序?
谢谢!
最佳答案
来自 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.
关于javascript - 哪个更适合 jQuery.ajax 调用? .Net Web 服务还是 .ashx?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5543069/